A Date With Tim Peters...
Tim Peters
tim_one at email.msn.com
Tue Dec 7 22:23:53 EST 1999
[Tim]
>>> import math
>>> zero = 0.0
>>> math.atan2(zero, zero)
0.0
>>> zero = -zero
>>> math.atan2(zero, zero)
-3.14159265359
>
> That is, IEEE-754 mandates signed zeroes too, in part so that an
> underflow "remembers which direction it came from".
[Rob W. W. Hooft]
>>> Python 1.5.2b1 (#4, Jan 14 1999, 12:05:48) [GCC egcs-2.90.21
>>> 971202 (egc on irix5
>>> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import math
>>> zero=0.0
>>> math.atan2(zero,zero)
Traceback (innermost last):
File "<stdin>", line 1, in ?
ValueError: math domain error
> no11[101]nonius% uname -a
> IRIX no11 5.3 02091401 IP22 mips
>
> So it is not portable.....
Of course not -- nothing having to do with floating point is portable, and
won't be until C mandates something non-trivial about it. Even then, there
are a dozen old & incompatible "add on" libm stds to contend with. It's in
the spirit of the 754 std to return the results I showed; the domain error
you got is historical baggage.
> IIRC, on a VAX Using -0.0 would result in an "operand reserved to
> digital" fault.
You mean WinTel is the only platform that does this right <wink>?
if-the-pentium-didn't-do-this-all-by-itself-ms-would-get-it-
wrong-too-ly y'rs - tim
More information about the Python-list
mailing list