4

I've got a weird case using Python to get the result of this calculation:

11.66 * 0.98 * 1.05 + 1.7 + 0.70 * 1.03

in Python the result that I got is 14.41914

but when my customer calculate it using their calculator and iPhone the result that they got is 14.8300842

so which is the correct result ? and what caused this calculation to have different result ? thanks

3 Answers 3

10

The correct result is the one Python gave you. Your customer is using a calculator that doesn't account for order of operations, or has used the calculator in such a way that order of operations information was discarded.

Sign up to request clarification or add additional context in comments.

1 Comment

stupid of me to figure it out now, thanks ur for guidance dude :)
7

What your customer seems to have done is this:

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

whereas that expression in python:

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

Does the multiplies first:

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

Its a very strong convention that multiplication is done first, but desk calculators (real and appy) have to work on the numbers as they are punched in, so might do different things.

1 Comment

reverse calculating ftw!
2

14.41914 is right.

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

So they just ignore the calculation order of adding and multiplication.

1 Comment

If only RPN calculators had caught on, we wouldn't be in this mess!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.