This is confusing me so any help explaining this would be helpful. 1) a byte has 8 bits of storage. The MSB is the left bit and 1 indicates negative and 0 indicates positive. 2) byte range is -128 to 127. Since there are only 7 bits of storage(as 1 bit is used for the sign) how does it store -128? e.g., 01111111 is 127 and 11111111 is -127 in binary 128 is 10000000 (so how can a byte hold -128? confused please help! Andy
In a byte if you don't have a sign bit then, 128 = 10000000 So lets see how to get -128 from this: 1. First invert/complement the bits: 01111111 2. Then add 1 to it: 10000000 So, this represents -128 in two's complement form. With the first bit indicating the sign bit. Until and unless I have forgotten the principles of digital logic that I learnt 12 years ago ...
posted 18 years ago
Thanks robs its Twos complement then right ie: I got this for how to calculate negative binaries Thanks Andy
How to find the Twos Complement of a number: A Quick Method Suppose we want to find the twos complement 6-bit representation of -14 (1.) First, we write down the positive binary number, in this case 14 14 - 001110 (2.) Now, start writing the digits from the right hand side up to and including the first 1. In our case, just 10. (3.) Then invert the rest of the digits. So our answer becomes 110010. That's all!