no sign() function ?

ajaksu ajaksu at gmail.com
Tue Dec 23 11:27:53 EST 2008


On Dec 22, 9:18 am, Christian Heimes <li... at cheimes.de> wrote:
> Sure? :) Are you aware that the IEEE 754 standard makes a difference
> between the floats +0.0 and -0.0?
>
> from math import atan2
> def sign(x):
>     if x > 0 or (x == 0 and atan2(x, -1.) > 0.):
>         return 1
>     else:
>         return -1

Is "x ** 0 > 0." instead of "atan2(x, -1.) > 0." unreliable across
platforms?





More information about the Python-list mailing list