newbie seeks inaccurate arithmetic insight
Stanley Krute
StanleyKrute at starband.net
Mon Apr 30 12:56:16 EDT 2001
Hi Fredrik
> try using "%.17g" (show all significant digits) instead of "%f" (fudge it)
Aha ! Python defaults to Truth !
Verifying: Here's my c output using %.17g :
http://static.userland.com/images/stanleydaily/carithmetic17g.gif
The inaccuracies exist 15 or so places to the
right of the decimal point.
In the Python test
http://static.userland.com/images/stanleydaily/pythonarithmetic.gif
the inaccuracies also exist 15 or so places to the right of the decimal
point. Interestingly, in this particular test case, because the answers run
beneath the ideal, the inaccuracies propagate their visibility to just 2 or
3 places to the right
of the decimal point.
> ...or use "print" in Python, to get str() instead of repr() behaviour:
Thanks for the tip !
Stan
just newbying along ....
More information about the Python-list
mailing list