Re: 8.5 beta and decimal precision handling



On 28 sep, 15:15, keithv <kvet...@xxxxxxxxx> wrote:
On Sep 28, 3:24 am, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:



On 27 sep, 21:22, keithv <kvet...@xxxxxxxxx> wrote:

I just decided to try 8.5 beta on Windows and see how
it works with some of my software.

I found that tip #132 "Revised floating-point
conversions in Tcl" is causing problems.
Specifically, floating point numbers are
being displayed with much more precision than
the user expects. To wit:

pack [label .l -textvariable foo]
set foo [expr {2.7 + 0.6}]
==> label shows up as 3.3000000000000003

I was wondering how people are handling this.

I guess I could set tcl_precision back to 12, but the tip
says that doing so is deprecated.

Thanks,
Keith

There are very good reasons for the change (shimmering
can no longer influence the value), but as Michael
suggests, to mitigate the above effect, you should
use [format] (and perhaps traces).

Yuck, that seems like a step backwards.

Aren't you basically saying that -textvariable is useless
for real number fields? (Once you've got the trace, just
config the widget instead of using a shadow variable.)

Personally, in 10+ years of tcl programming, I've never
encountered the problem tip 132 is fixing, but now in just
one of my applications I have over 100 widgets I must hack up.

Keith

Well, you can still use tcl_precision, even if it is said to be
deprecated. As I am more inclined to think of numbers as, well,
numbers rather than their decimal representation, I appreciate
the tip (plus I come from a comma-oriented culture :))

Regards,

Arjen

.



Relevant Pages

  • Re: 8.5 beta and decimal precision handling
    ... conversions in Tcl" is causing problems. ... use (and perhaps traces). ... config the widget instead of using a shadow variable.) ... Personally, in 10+ years of tcl programming, I've never ...
    (comp.lang.tcl)
  • Re: 8.5 beta and decimal precision handling
    ... conversions in Tcl" is causing problems. ... config the widget instead of using a shadow variable.) ... Personally, in 10+ years of tcl programming, I've never ... had the need for format earlier already. ...
    (comp.lang.tcl)
  • Tcl-URL! - weekly Tcl news and links (Dec 11)
    ... Tcl packages for different operating systems. ... The aim of this extension is to allow Tcl developers to produce Mac ... this widget provides the correct variation to each set of users. ... other platforms, they render as standard Tile buttons. ...
    (comp.lang.tcl)
  • Dr. Dobbs Tcl-URL! - weekly Tcl news and links (Sep 20)
    ... Dear Tcl Community. ... Tablelist is a library package for Tcl/Tk version 8.0 or higher, ... - a second demo script, implementing a simple widget browser based on ...
    (comp.lang.tcl)
  • Re: Tk Button-Design
    ... >>> Anzahl von Widget Sets und Toolkits, die Tk im doppelten Wortsinn alt ... > Tcl selbst hat schwerste Design-Fehler und ist faktisch tot. ... > Tk-Programme mit Perl und Tcl geschrieben. ... "modernen" Toolkits hat man Probleme, wenn das System nicht ein Linux ...
    (de.comp.lang.perl.misc)