On 5/26/07, lorenzo bolla <[EMAIL PROTECTED]> wrote:
Hi all. I have to work with floating point arithmetics and I found a module called "double module" (http://symptotic.com/mj/double/public/double-module.html ) that does what I'd like. Basically, I would like to find the nearest smaller and bigger floating point numbers, given a "real" real number (the function doubleToLongBits<http://symptotic.com/mj/double/public/double-module.html#doubleToLongBits> can be used to do just that.). Is there something similar in numpy? In other words: is there a way, in numpy, to convert a floating point number to its binary representation and back?
I don't quite understand what problem you are trying to solve. Python doubles are, I believe, the same as the C doubles supported by the hardware, i.e., IEEE754 doubles. Correct me if I am wrong. If you just what the same bits in a long, do In [5]: float64(3.0).view(int64) Out[5]: 4613937818241073152 To see it in hex: In [6]: hex(float64(3.0).view(int64)) Out[6]: '0x4008000000000000L' Note that you need to keep endianess in mind to interpret the results. Chuck Thank you and regards,
L.
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
