Movatterモバイル変換


[0]ホーム

URL:


Floating point (in)accuracy?

Alex Martellialeaxit at yahoo.com
Wed Apr 25 12:59:42 EDT 2001


"Dinu Gherman" <dinu at reportlab.com> wrote in messagenews:3ae6eb73.802364759 at news.vr.in-berlin.de...> Apparently the python mailiing lists on python.org are blocked, so let> me ask here. Is there any good reason for the following behaviour to> be different on Python 1.5.2 and 2.0?    [snip]>   >>> 3.14>   3.14    [snip]>   >>> 3.14>   3.1400000000000001Yes: repr(x) where x is a float used to HIDE some digits (trying toprovide a 'prettier' look), but that violates the mission of repr, whichis to give you as much info as it can.  Now, repr(x) "tells the truth";use str(x) to get prettier (false:-) output.  The interpreter uses repr.You can change that in Python 2.1, by setting sys.displayhook toyour favourite "display this result to sys.stdout" function, but thatwas not in 2.0 yet.Alex


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp