1

Given the following expression:

-7 + 1 - 8 * -10 / 28 - 67 + -54

I resolve it thus:

-7 + 1 - -80 / 28 - 67 + -54

-7 + 1 - -2 - 67 + -54

-6 - -2 - 67 + -54

-4 - 67 + -54

-71 + -54

-125

However various online calculators say the answer is:

-124.14285714285714

What am doing wrong?

tuk
  • 111
  • 1

2 Answers2

1

The main issue here is in the second line where you simplify $-80/28$ to equal $-2$. In fact, (-80/28) = (-20/7). So the resulting sum simplifies to $-127 + 20/7$ which does in fact expand to -124.1428...

Fluff aside, I think the real problem here is you're confusing $8$ with $0$ on whatever device you are using. Although if that were true then how come you typed 80 correctly?

0

-80 / 28 = -2.857142857142857

Not the -2 stated in question working.
Changing this value now gives the same final result as the online calculators:

-124.14285714285714

Note: My code was casting the: -2.857142857142857 to an integer(not a double): -2

So losing: -0.857142857142857 on the conversion.

tuk
  • 111
  • 1