Both of these allow us to represent negative (and positive numbers)
Signed bit uses the first "bit" to indicate positive or negative
i.e 1 0 0 0 0 0 0 1 = - 1 (we disregard the first bit after finding out its sign)
this gives us a few problems
first, we lose RANGE, for an 8 bit number we can only represent 2 ^ 7 numbers (because we chucked a bit away)
You may also have noticed that there are two zeros
1 0 0 0 0 0 0 0 = negative zero
0 0 0 0 0 0 0 0 = postitive zero
Two's Complement works similarly, the first digit tells you positive or negative.
If its a 1 (negative) we invert the number and add one
If its positive we treat it like a normal binary number
Tuesday, 21 August 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment