This math scares me

Tim Peters tim.one at home.com
Mon Mar 12 23:41:37 EST 2001


[Andrew Koenig]
> I'm curious -- Does Python now follow either the IEEE or the more
> restrictive Scheme rules for floating-point conversion?
> ...

All aspects of Python fp are inherited from whatever the platform C compiler
and libraries happen to do.  repr() conversion to string uses the platform
sprintf's %.17g format; str() conversion %.12g; both are fiddled just a
little to ensure that an exponent or a decimal point (or both) appears.
string->float is a x-platform adventure, since some platforms can't read back
all the C doubles they print (thinking of infinities and NaNs here); Python
inherits that too, whenever it happens.

it's-all-x3j11's-fault<wink>-ly y'rs  - tim





More information about the Python-list mailing list