Re: 8.5 beta and decimal precision handling
- From: Arjen Markus <arjen.markus@xxxxxxxxxx>
- Date: Fri, 28 Sep 2007 06:47:25 -0700
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
.
- 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: "package ifneeded" and "catch" - I think, it's a misbehaviour.
- 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
|