0

When I calculate below division in python, the result returns as 1. How do I get the actual float number?

1/(1+3.0573630308660312e-30)
Out[182]: 1.0
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
mebugayan
  • 11
  • 2
  • You can't, not with `float`. `(1+3.0573630308660312e-30)` is 1.0, because floating point numbers can't represent that small a fraction over 1. The limit is `sys.float_info.epsilon`, roughly 16 decimal digits small. – Martijn Pieters Feb 22 '20 at 17:44
  • If you need to work with offsets from 1 *this small*, use the `decimal.Decimal` type. – Martijn Pieters Feb 22 '20 at 17:45

0 Answers0