An integer is a number with a sign, so it can be negative, zero or positive. The rule is: let the most significant bit be sign bit. If it is on, the number is negative. The way you do that is to add the largest negative number to the 0 to n count of the number.
Try this with one bit. Its most significant bit is the only bit. Its largest negative number is 1.
The integer is -1 and 0. Not very useful.
With two bits, we have an integer. Here we have
count, two bit count, integer and integer value.
0 00 10 -2
1 01 11 -1
2 10 00 0
3 11 01 1
This matches all integers as long as the most significant bit is observed. (To add a two bit integer to an x bit integer, shift the two bit integer until its matched with the most significant bit of the x bit integer.)
To make an x bit integer, add (or subtract) the largest negative number from the count number. For 8 bits you add 80h to xxh to get the integer.
00h 80h
01h 81h
02h 81h
...
7Fh FFh
80h 00h
...
FFh 7Fh
Smallest integer
Smallest integer
Harold L. Reed
Microbes got brains
Microbes got brains
Who is online
Users browsing this forum: No registered users and 3 guests