With Python 3.4.3
int(1 / 1e-3)
1000
int(1 / 1e-4)
10000
int(1 / 1e-5)
99999
int(1 / 1e-6)
1000000
int(1 / 1e-7)
10000000
Bug or Feature? Any particular reason?
With Python 3.4.3
int(1 / 1e-3)
1000
int(1 / 1e-4)
10000
int(1 / 1e-5)
99999
int(1 / 1e-6)
1000000
int(1 / 1e-7)
10000000
Bug or Feature? Any particular reason?
floating point numbers aren't exact. Only binary numbers are.
>>> '%.25f' % 1e-5
'0.0000100000000000000008180'
>>> '%.25f' % (1/1e-5)
'99999.9999999999854480847716331'
So 1/1e-5
is less than 100000
and int
cuts off the fractal part.
Converting to int, rounding is the answer:
>>> int(round(1/1e-5))
100000