I have two numbers(in decimal):
M = 3892.74
N = 9341.65
I am trying to add and subtract them in binary numbers and then in hexadecimal numbers. I manage to convert the numbers into binary/ hexadecimal with 4 fraction digits.
M = 111100110100.1011 and M = f34.bd70
N = 10010001111101.1010 and N = 247d.a666
and I have found M + N = 13234.51 =わ 11001110110010.0101 = 33b2.83d6
I am having trouble doing the M - N ? Is there negative numbers in alternate number systems and how would I carry out this subtraction ? If my earlier work can be verified, I would also appreciate it. Thanks
1 Answer 1
M - N can be done in the usual way as:
00111100110100.1011 -
10010001111101.1010
---------------------
1 10101010110111.0001
---------------------
We have a borrow here. Answer is negative and is in 2's complement form.
Or you can add the 2's complement of N with M.
-N = 2's complement of N = 101101110000010.0110
0 00111100110100.1011 +
1 01101110000010.0110
---------------------
1 10101010110111.0001
---------------------
Take the 2's complement of this number to get -01010101001000.1111 = -5448.9375
.
2's complement
to make one of the numbers negative, then subtract by adding the 2's complement. \$\endgroup\$