binary - 01 1011 - 11 1101 = ? use 2's complement -


i'm trying figure out doozie: 01 1011 - 11 1101

use 2's complement solve, 6bits signed.

this tried:

range of 6bits: -32 31

01 1011 = 27

11 1101 = -29

27 -(-29) = 56 (overflow)

11 1101 -- 2s complement --> 10 0011

so

01 1011 + 10 0011 = (missing bit)11 1110 = -2!

any luck?

ok think figured out:

my first mistake 11 1101 not -29 -3.

so:

01 1011 = 27

11 1101 = -3

27 -(-3) = 30

i can reverse 2's complement of -3 is:

11 1101 - 1 = 11 1100

then flip 11 1100 gives me 00 0011.

so

01 1011 + 00 0011 = 01 1110 = 30

:)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -