Single precision floating point calcs?
sturlamolden
sturlamolden at yahoo.no
Thu May 10 09:50:58 EDT 2007
On May 9, 6:51 pm, Grant Edwards <gra... at visi.com> wrote:
> Is there any way to do single-precision floating point
> calculations in Python?
Yes, use numpy.float32 objects.
> 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...
Numpy has scalars as well.
>>> import numpy
>>> a = numpy.float32(2.0)
>>> b = numpy.float32(8.0)
>>> c = a+b
>>> print c
10.0
>>> type(c)
<type 'numpy.float32'>
>>>
More information about the Python-list
mailing list