Grant Edwards wrote: > I'm pretty sure the answer is "no", but before I give up on the > idea, I thought I'd ask... > > Is there any way to do single-precision floating point > calculations in Python? > > I know the various array modules generally support arrays of > single-precision floats. I suppose I could turn all my > variables into single-element arrays, but that would be way > ugly...
We also have scalar types of varying precisions in numpy: In [9]: from numpy import * In [10]: float32(1.0) + float32(1e-8) == float32(1.0) Out[10]: True In [11]: 1.0 + 1e-8 == 1.0 Out[11]: False If you can afford to be slow, I believe there is an ASPN Python Cookbook recipe for simulating floating point arithmetic of any precision. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list