I want a
to be rounded to 13.95.
>>> a
13.949999999999999
>>> round(a, 2)
13.949999999999999
The round
function does not work the way I expected.
I want a
to be rounded to 13.95.
>>> a
13.949999999999999
>>> round(a, 2)
13.949999999999999
The round
function does not work the way I expected.
Try the code below:
For fixing the floating point in type-dynamic languages such as Python and JavaScript, I use this technique
You can also use Decimal as following: