confusion in arithmetic addition

Thread Starter

annujain501

Joined Jul 28, 2010
6
i am having hard time in addition of numbers in same base..!!! here are two of such questions

1) (FE) + (78) = ? {all in base-16}

using the logic as understand,solution i infer :

FE
78


E+8=14+8=22---> 15+7---> F+7---> therefore,7 is carry

7
FE
78
F
similarly 7 + F +7= F+E;


7
FE
78
EFF

2) x567 +27x5 = 75yx (all in base-8)

if i use the logic same as above,i get :

x567
27x5

7+5= 12---> 5 is carry;x=7

5
x567
27x5----> 2755
75y7


5+6+5=16--->7+8;y=7

now 8+5+7=20----> this is obvly...wrong....

where i m getting wrong..??
 
Last edited:

beenthere

Joined Apr 20, 2004
15,819
Do the math in binary -

(FE) 1111 1110
(78) 0111 1000
(176)1 0111 0110

Convert to decimal - FE is 254, 78 is 120, sum is 374. 374d is 176h
 

jpanhalt

Joined Jan 18, 2008
11,087
E+8=14+8=22---> 15+7---> F+7---> therefore,7 is carry
There are all sorts of workarounds, such as converting to decimal or binary, but I hope you now see your basic error: there is a place holder for when the sum equals the base.

Look at, for example, 8d + 2d = 0d plus carry 10 (or one "10").

Eh +2h = 0h plus carry 10h (one 16, that is).

Similarly, in your example and using your symbols, E + 8 = 14 +8 = 22 ---->6 plus carry 10 (one 16, that is).

John
 

Thread Starter

annujain501

Joined Jul 28, 2010
6
There are all sorts of workarounds, such as converting to decimal or binary, but I hope you now see your basic error: there is a place holder for when the sum equals the base.

Look at, for example, 8d + 2d = 0d plus carry 10 (or one "10").

Eh +2h = 0h plus carry 10h (one 16, that is).

Similarly, in your example and using your symbols, E + 8 = 14 +8 = 22 ---->6 plus carry 10 (one 16, that is).

John
one thing that i understood is that i cannot take 7 as carry because it not of the same radix system.
okay,but i didnt got the idea of 'one "10"' carry
and therefore in my problem 6 plus 10h as carry :(

could you explain it in elaboration..??:)
 

Thread Starter

annujain501

Joined Jul 28, 2010
6
Do the math in binary -

(FE) 1111 1110
(78) 0111 1000
(176)1 0111 0110

Convert to decimal - FE is 254, 78 is 120, sum is 374. 374d is 176h

yes,this could be the way out but when we go for MCQs this procedure may consume time unnecessarily.
so we go for a method that is both accurate and less time consuming.:)
 

Papabravo

Joined Feb 24, 2006
22,116
i am having hard time in addition of numbers in same base..!!! here are two of such questions

1) (FE) + (78) = ? {all in base-16}

using the logic as understand,solution i infer :

FE
78


E+8=14+8=22---> 15+7---> F+7---> therefore,7 is carry

7
FE
78
F
similarly 7 + F +7= F+E;


7
FE
78
EFF

2) x567 +27x5 = 75yx (all in base-8)

if i use the logic same as above,i get :

x567
27x5

7+5= 12---> 5 is carry;x=7

5
x567
27x5----> 2755
75y7


5+6+5=16--->7+8;y=7

now 8+5+7=20----> this is obvly...wrong....

where i m getting wrong..??
You need to make yourself a hexadecimal addition table. Then you do the problem in hex. For example:
Rich (BB code):
  0xFE
+ 0x78

E + 8 = 0x16 so you put down the 6 and carry the 1
F + 7 + 1 = = 0x17 so you put down the 7 and carry the 1
1 + 0 = 1 so the answer is 0x176
If we are dealing with 8-bit registers then of course the answer becomes 0x76 and the carry gets lost. That is what happens in modulo arithmetic

Second problem requires an octal addition table. I do this stuff in my head because I learned it 51 years ago when I was in the 7th grade.

Rich (BB code):
  x567
+ 27x5
-------
  75yx

7 + 5 = 014 so x = 4 and we carry a 1
6 + 4 + 1 = 013 so y = 3 and we carry a 1
5 + 7 + 1 = 015 so we put down a 5 and carry a 1
4 + 2 + 1 = 007 so we put down the 7 and there is no carry
AND - Tah dah everything is right with the world.
 

Thread Starter

annujain501

Joined Jul 28, 2010
6
You need to make yourself a hexadecimal addition table. Then you do the problem in hex. For example:
Rich (BB code):
  0xFE
+ 0x78

E + 8 = 0x16 so you put down the 6 and carry the 1
F + 7 + 1 = = 0x17 so you put down the 7 and carry the 1
1 + 0 = 1 so the answer is 0x176
If we are dealing with 8-bit registers then of course the answer becomes 0x76 and the carry gets lost. That is what happens in modulo arithmetic

Second problem requires an octal addition table. I do this stuff in my head because I learned it 51 years ago when I was in the 7th grade.

Rich (BB code):
  x567
+ 27x5
-------
  75yx

7 + 5 = 014 so x = 4 and we carry a 1
6 + 4 + 1 = 013 so y = 3 and we carry a 1
5 + 7 + 1 = 015 so we put down a 5 and carry a 1
4 + 2 + 1 = 007 so we put down the 7 and there is no carry
AND - Tah dah everything is right with the world.

thank u so much sir,i think this is exactly what i need to understand...

but sir how do calculate E+8=0x16 and why have we taken FE as 0xFE? if i could understand this everything will become clear.
 

Papabravo

Joined Feb 24, 2006
22,116
Using a prefix of "0x" to denote a hexadecimal number is a convention I first learned in from "The C Programming Language" by Kernighan & Ritchie. Similarly a leading 0 denotes a number in octal (base-8) notation. I use these conventions almost without thinking and assume that everybody knows and understands them. It was presumptuous and I apologize.
 
Top