----- Original Message ----- From: "Will Coleda" <[EMAIL PROTECTED]>

To properly support $tcl_precision in tcl, I need to change how I'm
currently implementing {$tcl_precision == 0}. Right now, I just fake
it by setting the precision to 16, but that isn't right.


where something like
{expr acos(0)} should output:

1.5707963267948966

it outputs (with the above C code)

1.5708

And in partcl's current state, it outputs

1.570796326794897


A few points to ponder.
1) The default precision for %g in C is 6 significant digits, i.e. 1.57080 (but sprintf drops trailing zeroes) 2) 1.5707963267948966 actually corresponds to 17-digit precision (which is the limit for double), not 16 3) tcl uses its own special handling for tcl_precision = 0, refer to http://www.tcl.tk/cgi-bin/tct/tip/132.html for more information 4) Look at David Gay's code (see http://www.netlib.org/fp/index.html, specifically gdtoa) for similar logic 5) Although I haven't looked, the tcl source code must contain their actual implementation

I don't know whether we expect enough usage of Parrot in mathemetical circles to be worthwhile adding one of these implementions to our version of sprintf.

Regards
Peter Gibbs

Reply via email to