[Python-Dev] small floating point number problem (original) (raw)
Smith smiles at worksmail.net
Wed Feb 8 07🔞54 CET 2006
- Previous message: [Python-Dev] threadsafe patch for asynchat
- Next message: [Python-Dev] small floating point number problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I just ran into a curious behavior with small floating points, trying to find the limits of them on my machine (XP). Does anyone know why the '0.0' is showing up for one case below but not for the other? According to my tests, the smallest representable float on my machine is much smaller than 1e-308: it is
2.470328229206234e-325
but I can only create it as a product of two numbers, not directly. Here is an attempt to create the much larger 1e-308:
a=1e-308 a 0.0 a==0 True <-- it really is 0; this is not a repr issue b=.1*1e-307 b 9.9999999999999991e-309 a==b False <--they really are different
Also, I see that there is some graininess in the numbers at the low end, but I'm guessing that there is some issue with floating points that I would need to read up on again. The above dilemma is a little more troublesome.
m=2.470328229206234e-017 s=1e-307 m*s 4.9406564584124654e-324 #2x too large 2ms 4.9406564584124654e-324 3ms==4ms True
/c
- Previous message: [Python-Dev] threadsafe patch for asynchat
- Next message: [Python-Dev] small floating point number problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]