OOT: Negative number multiplication
Florian Diesch
diesch at spamfence.net
Thu May 25 03:41:05 UTC 2006
Groundhog <linuxmurah at gmail.com> wrote:
> few weeks ago I had a question, acctually really simple question, but
> until today nobody can give me answer. okay here is my question:
>
> "as we know since Elementary School:
> (+) x (+) = (+)
> (+) x (-) = (-)
> (-) x (+) = (-)
> (-) x (-) = (+)
>
> now when I change with numbers:
> 5 x 3 = 5 + 5 + 5 = 15 (everybody know this very well)
> 5 x (-3) = ....................... = -15 (everybody getting confused)
> (-5) x (3) = (-5) + (-5) + (-5) = -15 (no problem with it)
> (-5) x (-3) = ....................... = 15 (then, everybody get frustated)
>
> could someone give answer about this 'elementary' question??
First let's define what negative numbers are:
a. (-1) = 0-1
b. For every number n: (-n) = (-1)*n
So what's -3?
It's (-1)*3 = (0-1)*3 = 0*3-1*3 = 0-3 = 0+((-1)*3) = 0+(-3) = -3
Looks good.
Let's look at 5*(-3):
5*(-3) = 5*((-1)*3)
= 5*((0-1)*3)
= 5*((0*3)-(1*3))
= 5*(0-3)
= 5*0-5*3
= 0-15
= (0-1)*15
= (-1)*15
= -15
And now (-5)*(-3):
(-5)*(-3) = ((-1)*5)*((-1)*3)
= (-1)*(-1)*5*3
= (0-1)*(0-1)*15
= (0*0-0*1-1*0-1*(-1))*15
= (0-0-0-(-1))*15
= (-(-1))*15
= (-(0-1))*15
= ((-0)+1)*15
= 1*15
= 15
Florian
--
<http://www.florian-diesch.de/>
More information about the ubuntu-users
mailing list