r/programminghomework • u/Blindbyakko • Nov 20 '17
Binary question(maybe misc others)
So i'm trying to study for my exam, using a previous assignment i did, but i can't figure out why i got the question incorrect.
Question - What does the number 1000000_2 represent in decimal? (two's compliment)
I thought i would just compliment the bits( going from 10000000 ->> 11111111_2 then add 1. Which would give me [1]00000000. So in decimal i would have 0(tossing the overflow bit) Where did i go wrong?
1
Upvotes
View all comments
Show parent comment
1
u/Blindbyakko Nov 20 '17
ooohhh so i add them together first. so 1000 0000 + 1111 1111 = [1]0111 1111(toss overflow) which would give me 127. But if i say got something like 1000 0001 for my i would flip them all then add 1, correct?( example : 1000 0001 > 0111 1110 + 1 > 0000 0001(but add 1 at end since it's negative, for -1)