2

I just have a quick question regarding one's complement with binary numbers that maybe someone could help me understand.

I am studying for a computer security test and I am practicing converting decimal numbers to binary numbers and then using one's and two's complement. I am given the decimal number 237 and converted it to 11101101 in binary. I understand that in one's complement you reverse the bits and it is simple. When I reversed it I get 00010010 but the answer leaves out the first three 0's. Any chance someone could explain to me why that is?

2 Answers2

0

The value 237 is too large to be stored in a single 8 bit signed byte with one's complement. If it were stored in a 16-bit int instead, it, and its one's complement negations would have the respective representations in base 2:

0000000011101100

1111111100010011

When doing arithmetic like this by hand, keep a few extra digits on the left of your number to account for the sign of the number if you plan to negate the bits later.

Govind Parmar
  • 20,656
  • 7
  • 53
  • 85
0

Those leading 0's don't hold any significance. Basically, in decimal one can say 07 == 7 == 00000000007, so in binary equally 00010010 == 10010 == 0000000000000010010 holds.

Bart Van Loon
  • 1,430
  • 8
  • 18