The values must divided by 1e15?
You can use decimal.Decimal and change the precision, but Decimal is slow.
Are you using a 32 bit version of Python?
With numpy I got following (Python 3.7.3 x64):
You can use decimal.Decimal and change the precision, but Decimal is slow.
import decimal def convert(integers, divisor='1e15'): with decimal.localcontext() as ctx: ctx.prec = 20 for value in integers: yield decimal.Decimal(value) / decimal.Decimal(divisor) list(convert(['2229708157109627', '2204081406354342']))
Output:[Decimal('2.229708157109627'), Decimal('2.204081406354342')]
Numpy has a float128 datatype, but 64 seems to be enough to represent the value.Are you using a 32 bit version of Python?
With numpy I got following (Python 3.7.3 x64):
In [34]: import numpy as np In [35]: np.float128(num) Out[35]: 2229708157109627.0 In [36]: np.float64(num) Out[36]: 2229708157109627.0 In [37]: np.float32(num) Out[37]: 2229708100000000.0 In [38]: np.float128(num) / 1e15 Out[38]: 2.229708157109627 In [39]: np.float64(num) / 1e15 Out[39]: 2.229708157109627 In [40]: np.float32(num) / 1e15 Out[40]: 2.22970811252736 In [41]: num / 1e15 Out[41]: 2.229708157109627 In [42]: num Out[42]: 2229708157109627
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!