Home > other >  Python3.6 subtract 2.2 2.1 indicates 0.1 error
Python3.6 subtract 2.2 2.1 indicates 0.1 error

Time:10-10

I use qpython3L on a mobile phone, found 2.2-2.1=0.10000000009, is this why? So also on the computer?

CodePudding user response:

computer floating-point Numbers is approximate calculation,

CodePudding user response:

Tried it on the computer in C language, adjust to % 0.20 f, also is such,

CodePudding user response:

On a computer, so should be associated with floating point number

CodePudding user response:

The floating point number itself, precision insufficient

Need high precision digital, especially the financial sector, the use of a decimal. Decaimal

CodePudding user response:

A slip of the pen is a decimal. A decimal

CodePudding user response:

reference 4 floor tianfang response:
the floating-point number itself, precision insufficient

Need high precision digital, especially the financial sector, the use of a decimal. Decaimal

Use a decimal after, there is still a "tail", although higher precision, tail is longer,

CodePudding user response:

Using the python, decimal module
A Decimal (' 2.2 ') - a Decimal (' 2.1 ')
Do with string parameters

CodePudding user response:

Python floating point exist uncertain mantissa
  • Related