Looking for the greatest negative float value
Mel Wilson
mwilson at the-wire.com
Wed Jun 11 17:10:48 EDT 2003
In article <bc7lvb$gm3$1 at news-reader12.wanadoo.fr>,
"Gilles Lenfant" <glenfant at NOSPAM.bigfoot.com> wrote:
>Hi,
>
>I need the same as...
>
>import sys
>negmaxint = - sys.maxint -1
>
>... but for float data
>
>any hint ?
I'm not completely sure this is right, but..
v, w, x = -1.0, 0.0, 0.0
i = 0
while v < w and i < 2000:
x, w, v = w, v, v*2.0
i += 1
print i
print x, w, v
d = -x / 2.0
y = x
while x > w:
y, x = x, x-d
d /= 2.0
print repr (y)
winds up printing
1025
-8.98846567431e+307 -1.#INF -1.#INF
-1.7976931348623157e+308
and that last number seems credible.
Regards. Mel.
More information about the Python-list
mailing list