[Numpy-discussion] floating point arithmetic issue

Alan G Isaac alan.isaac@gmail....
Fri Jul 30 08:19:43 CDT 2010


On 7/30/2010 8:21 AM, Guillaume Chérel wrote:
> is there no
> implementation of an "exact type"

You could use the fraction module:

>>> f = [Fraction(i,10) for i in range(10)]
>>> a = np.array(f, dtype=object)
>>> a
array([0, 1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10], dtype=object)

But I don't see why you would.  Your computation will
be approximate in any case.

Alan Isaac


More information about the NumPy-Discussion mailing list