Various calculation results using Python

I have a strange case using Python to get the result of this calculation:

11.66 * 0.98 * 1.05 + 1.7 + 0.70 * 1.03

in python i got 14.41914

but when my client calculates it using their calculator and iPhone, the result they got is 14.8300842

so what is the correct result? and what led to the fact that this calculation had a different result? thank

+4
source share
3 answers

The correct result is the one that Python gave you. Your client uses a calculator that does not take into account the order of operations, or uses a calculator so that information about the order of operations is discarded.

+10
source

, , :

>>> (11.66*0.98*1.05 + (1.7+0.7))*1.03
14.830084200000002
>>>

python:

>>> 11.66*0.98*1.05 + 1.7+0.7*1.03
14.419140000000001

:

>>> (11.66*0.98*1.05) + 1.7+(0.7*1.03)
14.419140000000001 

, , ( appy) , , .

+7

14.41914 is correct.

(((((11.66 * 0.98) * 1.05) + 1.7) + 0.70) * 1.03) = 14.8300842

Therefore, they simply ignore the calculation order of addition and multiplication.

+2
source

Source: https://habr.com/ru/post/1545625/


All Articles