0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ If you're doing this by hand, you can just put a negative sign in front like you normally would with decimal numbers. \$\endgroup\$ – Greg d'Eon Feb 5 '15 at 3:06
  • \$\begingroup\$ Use binary 2's complement to make one of the numbers negative, then subtract by adding the 2's complement. \$\endgroup\$ – MarkU Feb 5 '15 at 4:04
1
\$\begingroup\$

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.

\$\endgroup\$

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.