G
G
GineTik2020-07-24 22:03:29
Python
GineTik, 2020-07-24 22:03:29

Wrong calculations and how to fix it?

I have an example: 0.999999999988288 - 1.0
comes out: -1.1711964731375701e-11

although this should not be acceptable, what is it and how to fix it
and by the way if you bring 0.999999999988288 to 0.999 then: 0.999 - 1.0 =
-0.00100000000000

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kirillinyakin, 2020-07-25
@GineTik

What you got is called a floating point number, in order to adjust the number of decimal places you can write like this print('{:.2f}'.format(value)), but what you get is an inaccurate number, so this is normal, so this is a feature of the representation of floating point numbers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question