Description
Original ticket http://projects.scipy.org/numpy/ticket/1565 on 2010-07-28 by @fengy-research, assigned to unknown.
Prepare the following file:
-------file /tmp/test -----
9223372043271415339
9223372043271415853
9223372043271415612
9223372043271416107
9223372043271415594
9223372043271415836
9223372043761290139
9223372044088967272
9223372044088967273
9223372043925949039
---------end of file-----
And run the following code:
In [16]: print loadtxt('/tmp/test', dtype='uint64')
-------> print(loadtxt('/tmp/test', dtype='uint64'))
[9223372043271415808 9223372043271415808 9223372043271415808
9223372043271415808 9223372043271415808 9223372043271415808
9223372043761289216 9223372044088967168 9223372044088967168
9223372043925948416]
On the other hand, with fromfile(),
In [2]: print fromfile('/tmp/test', dtype='uint64', sep=' ')
------> print(fromfile('/tmp/test', dtype='uint64', sep=' '))
[9223372043271415339 9223372043271415853 9223372043271415612
9223372043271416107 9223372043271415594 9223372043271415836
9223372043761290139 9223372044088967272 9223372044088967273
9223372043925949039]
Clearly the first few numbers are wrongly converted by loadtxt
The problem was tracked to line 453 in numpy/lib/io.py, _getconv. The conversion for np.integer is int(float(x)), which is inexact for large integers.
I don't know if a priority of normal is appropriate, as this bug will produce hidden errors in programs that use numpy.