0

This more of a hw question but I cannot figure this one out. I thought it would be 214 but because of the first bit on the left, I am not so sure.

kevintdiy
  • 181
  • 2
  • 5
  • 13
  • Note you can check the *answer* at least in Windows 7's calculator (View>Programmer, set the word length to Byte, then set it to Bin, type in the number, and set it back to Dec). – lc. Feb 18 '13 at 00:55

3 Answers3

2

As it's a 2's complement number, the first bit being one means that it's a negative number.

The value is 214 - 256 = -42.

It can also be calculated as -(~214 + 1) = -(41 + 1) = -42.

Binary that would be -(~11010110 + 1) = -(00101001 + 1) = -00101010.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
1

the translation is simple:

1: substract 1 from x

11010110-00000001=11010101

2: invert it

00101010

3: calculate binary to dec (but ignore first bit)

2+8+32 = 42

4: remember the first bit of original value ( == 1) if 1 => invert it => -42

El Hocko
  • 2,581
  • 1
  • 13
  • 22
1

You can tell it's a negative number since there's a 1 in the leftmost bit position. One way you can get the magnitude is invert all the bits and then add 1.

11010110
00101001 <= inverted
00101010 <= +1

This result is decimal 42, so the original value is representing -42.

808sound
  • 7,866
  • 1
  • 15
  • 13