[Numpy-discussion] Printing individual array elements with at least 15 significant digits

Hugo Gagnon sourceforge.numpy@user.fastmail...
Sat Oct 15 14:21:54 CDT 2011


Hello,

I need to print individual elements of a float64 array to a text file.
However in the file I only get 12 significant digits, the same as with:

>>> a = np.zeros(3)
>>> a.fill(1./3)
>>> print a[0]
0.333333333333
>>> len(str(a[0])) - 2
12

whereas

>>> len(repr(a[0])) - 2
17

which makes more sense since I am expecting at least 15 significant
digits…

So how can I print a np.float64 with at least 15 significant digits
(without repr!)?


More information about the NumPy-Discussion mailing list