Negative values

Posts 15 of 5 · Page 1 of 1
Negative values
I just started reading the AoA and I'm already confused. The high order bit is supposed to be the most left bit.

Here's how the book explains negative values.

In the two's complement system, the H.O. bit of a number is a sign bit. If the H.O. bit is zero, the number is positive; if the H.O. bit is one, the number is negative. Examples:

For 16-bit numbers:

8000h is negative because the H.O. bit is one. // H.O bit is 8, how is this one?

100h is positive because the H.O. bit is zero. // H.O bit is 1, how is this zero???

7FFFh is positive.

0FFFFh is negative.

0FFFh is positive.
Quote Originally Posted by BooYa View Post

For 16-bit numbers:

8000h is negative because the H.O. bit is one. // H.O bit is 8, how is this one?

100h is positive because the H.O. bit is zero. // H.O bit is 1, how is this zero???
LMAO. No wonder your having trouble...

That is hexadecimal my friend. the H.O. bit only has 2 states (on & off) so it must be represented in binary. you know (1000 0000). You see hxadecimal is used to represent binary more easily so that 8000h = 1000 0000 0000 0000 in binary.

Why does 8000h equal that you say? That is because in the H.O. bit is the 15th bit, with the L.O. bit being the 0th bit. So 2^15 = 32768 and 8*16(hex constant)^3 = 32768. SO see they are equal if you convert them into decimal form.


100h = 0110 0110 See and here the H.O. bit is off. Once you become better acquainted with the conversions understanding this will be a lot easier.

Just as a rule of thumb btw. two hex digits equal one byte. (00h = 0000 0000)
I don't understand how u converted them, i used the table they gave at chapter 1.3 AoA

8000h = 1000 0000 0000 0000 so it's negative

100h = 0001 0000 0000 so it's positive // not 100h = 0110 0110 like u said???

7FFFh = 0111 1111 1111 1111 so it's positive

0FFFFh = 0000 1111 1111 1111 1111 so it should be positive yet it's negative?

0FFFh = 0000 1111 1111 1111 so it's positive
Quote Originally Posted by BooYa View Post
I don't understand how u converted them, i used the table they gave at chapter 1.3 AoA

8000h = 1000 0000 0000 0000 so it's negative

100h = 0001 0000 0000 so it's positive // not 100h = 0110 0110 like u said???

7FFFh = 0111 1111 1111 1111 so it's positive

0FFFFh = 0000 1111 1111 1111 1111 so it should be positive yet it's negative?

0FFFh = 0000 1111 1111 1111 so it's positive
No, you can only have groups of eight binary digits. This is because eight bits make a byte. 0000 1111 1111 1111 1111 is 2.5 bytes, but the computer can only read one byte at a time so this is unrealistic, even if it is mathematically possible.


Here let me help you with the conversion. We will take it slow:

In decimal form:
90 = 9 groups of 10
90 also equals 9 * 10^1 = 90 That is 10 to the first power equals ten, so 9 * 10 = 90. You see every subsequent digit is multiplied by a power of ten. So 999 = (9 * 10^2) + (9 * 10^1) + (9* 10^0) = 900 + 90 + 9 = 999

So see a binary number would work the same way except every subsequent digit would be a multiple of 2 to what every power corresponds to the digits place. So 0001 = (1 * 2^0) = 1
0011 = (1*2^1) + (1*2^0) = 2 + 1 = 3
0111 = (1*2^2) + (1*2^1) + (1*2^0) = 4 + 2 + 1 = 7
finally 1111 = (1*2^3) + (1*2^2) + (1*2^1) + (1*2^0) = 8 + 4 + 2 + 1 = 15

Ok now that that's out of the way the conversion from hex to decimal also follows the same process:
Fh = 15 * 16^0 = 15
FFh = (15*16^1) + (15*16^0) = 240 + 15 = 255


Now before we go too far with hex conversions you should know that converting hex to binary is extremely easy, which is why hex was ever created in the first place. look at this:

Fh = 1111 Lol how easy was that
FFh = 1111 1111 See peice of cake

What about a digit other then F....

88h = 1000 1000 See I knew that 8 = 2^3 power So the 3rd bit must be 1 in each of these Nibbles (that is groups of 4 bits are commonly referred to as nibbles)

I hope this helped some. here try converting this to hex and then decimal:

0001 0001 =
Kudos for an excellent write up by Mr.Why
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?