Re: 8.5 beta and decimal precision handling
- From: schlenk@xxxxxxxxxxxxxxxx
- Date: Fri, 28 Sep 2007 06:35:49 -0700
keithv 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.
Basically your just lucky to have not to do much I18n otherwise you
might have
had the need for format earlier already.
e.g. in germany you would format 12.0 as 12,0 so directly using the
textvariable isn't an option
anyway if you want to support locale specific conventions for this
kind of stuff.
Michael
.
- References:
- 8.5 beta and decimal precision handling
- From: keithv
- Re: 8.5 beta and decimal precision handling
- From: Arjen Markus
- Re: 8.5 beta and decimal precision handling
- From: keithv
- 8.5 beta and decimal precision handling
- Prev by Date: Re: 8.5 beta and decimal precision handling
- Next by Date: Re: 8.5 beta and decimal precision handling
- Previous by thread: Re: 8.5 beta and decimal precision handling
- Next by thread: Re: 8.5 beta and decimal precision handling
- Index(es):
Relevant Pages
|