Reputation: 720
I am trying to round a floating point number but it returns zero. Why is that? How can I round my floating point number to 3 digits after decimal?
>>> a= 9.907283855185141e-32
>>> round(a,3)
0.0
>>> type(a)
<class 'float'>
Upvotes: 1
Views: 1314
Reputation: 122493
The number a
, if written in decimal, is
0.00000000000000000000000000000009907283855185141
If rounded to 3 digits after the decimal, it is in fact 0
.
Upvotes: 4