2
$\begingroup$

There's a question over on stack overflow about adding negative numbers to a negative number. The question surrounds why 10 - -5 is equal to 5.

I'm very happy that the result is 5, but why is it 5 and not 15. It is philosophical or is there a concrete reason for it?

The original question was asked here: https://stackoverflow.com/questions/5248734/odd-result-using-multiple-operator-in-c

UPDATE

So apart from the obvious transcription error, left in place for posterity, I think the original question stands. 10 - (-5) equals 15, fine, but at what point in mathematical history was this decided? In the same way the 0 wasn't always used there came a point in history when it was in common use. In the same way, when did a double negative become a positive in common mathematical parlance and more importantly why?

$\endgroup$
  • $\begingroup$ Typically one write $10+(-5)$ if one wants to add a negative number to a positive one. Your $10--5$ reads like $10-(-5)$ which in language means subtracting a negative number from a positive one. $\endgroup$ – Fabian Mar 9 '11 at 16:40
  • $\begingroup$ I'd like to see this question closed. $\endgroup$ – beroal Mar 9 '11 at 21:28
5
$\begingroup$

Below we prove $\rm\,\ 10\ -\ {-5}\ =\ 15\ $ is correct (more generally, see the Law of Signs).

$\rm\qquad\qquad \: n\ =\ 10\ \ -\ {-}5$

$\rm\quad\iff\ \ n\ +\ {-}5 \ =\ 10\quad $ by adding $\,-5\:$ to both sides of above

$\rm\quad\iff\ \ n \ =\ 10\ +\ 5\quad\ \ \ $ by adding $\, \ 5\ \ $ to both sides of above

Alternatively $\rm\ - (-x)\ =\: - (-x) +(-x + x) \ =\ (-(-x) + -x) + x\ =\ x$

i.e. both $\rm\: x\: $ and $\rm\:-(-x)\:$ are inverses of $\rm-x\:$ so they are equal by uniqueness of inverses.

The proof uses only the basic laws of arithmetic, that addition is associative and commutative, and every integer $\rm\:n\:$ has an additive inverse $\rm -n\:,\ $ i.e. the integers comprise an additive abelian group. The laws for negative integers weren't "decided" - they are forced upon us by "persistence of form", i.e. by requiring the the enlargement from naturals to integers obeys the same laws as the original structure. In particular, if you follow the above link you will see how the law of signs follows from the ring axioms - most notably the distributive law. The notion of a ring axiomatizes these familiar arithmetic properties of the integers, rational, polynomials, etc. The ring abstraction allows us to generalize properties of integers to diverse algebraic structures that share essential algebraic "integer-like" properties - structures which, in turn, may allow us to more simply deduce properties of the integers, e.g. solving Diophantine equations by passing to Gaussian integers or algebraic number fields. That we can pull back results from the general to more specific structures is only because of said persistence of form - the laws are the same whether the number is positive or negative, rational or irrational, real or imaginary. Thus whatever ring theorems we deduce about integers will specialize to true theorems about naturals, and whatever ring-theoretic properties we deduce about Gaussian integers $\rm\ m + n\ i\ $ will specialize to true properties of integers, simply because we invoked only ring laws that hold true universally, i.e. in every ring.

$\endgroup$
1
$\begingroup$

I think you've misinterpreted the SO thread. The poster was unhappy that the computer gave 15 for 10 - - 5 and he was (incorrectly) expecting the answer to be 5. It's not peculiar to C# either, all programming languages I know of work that way and that's the way basic arithmetic is taught. I don't see what the problem is.

$\endgroup$
1
$\begingroup$

You are not adding a negative number, you are subtracting it!
10-(-5)=15
10+(-5)=5
10+-(-5)=15

As for pholsophical reasons:
I am not unhappy = I am happy

$\endgroup$
  • $\begingroup$ As a matter of fact, I am not not not not not not not not unhappy, so let it be as such. $\endgroup$ – HyperKahlermanifold Apr 20 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.