03-15-2024, 05:54 PM
(This post was last modified: 03-15-2024, 05:56 PM by seanmcnally.)
Signed vs Unsigned really tripped me up, but I finally got it. Writing it out like this helped me understand:
For signed, starting at 0, the numbers keep increasing until the largest possible decimal number signed hex can represent (2,147,483,647), then suddenly flips to the biggest negative decimal number it can represent. However, looking at it this way, the crucial part to understand is that value in hex keeps increasing, even after the decimal number it represents makes the flip.
Signed Hex to Decimal
| 00000000 = 0
| 00000001 = 1
| 00000002 = 2
| (etc...)
| 7FFFFFFD = 2,147,483,645
| 7FFFFFFE = 2,147,483,646
| 7FFFFFFF = 2,147,483,647 <--- biggest possible decimal number in signed hex
| 80000000 = -2,147,483,647 <--- Sudden flip to the biggest negative!
| 80000001 = -2,147,483,646
| 80000002 = -2,147,483,645
| (etc...)
| FFFFFFFD = -3
| FFFFFFFE = -2
| FFFFFFFF = -1
v
hex value keeps
increasing
But if it's unsigned (logical), we don't make the flip at 80000000. We just keep increasing, which means we can represent double the amount of decimal numbers. Meaning, instead of the max being 2,147,483,647, the max is now double that, 4,294,967,295.
(if you just did that math yourself and are wondering why it came out to be one less, it's because we didn't have to repeat a number on the flip, so we get one bonus number in there.)
Unsigned (Logical) Hex to Decimal
| 00000000 = 0
| 00000001 = 1
| 00000002 = 2
| (etc...)
| 7FFFFFFD = 2,147,483,645
| 7FFFFFFE = 2,147,483,646
| 7FFFFFFF = 2,147,483,647
| 80000000 = 2,147,483,648 <--- No flip, number keeps increasing!!!!!
| 80000001 = 2,147,483,649
| 80000002 = 2,147,483,650
| (etc...)
| FFFFFFFD = 4,294,967,293
| FFFFFFFE = 4,294,967,294
| FFFFFFFF = 4,294,967,295 <--- biggest possible decimal number in unsigned hex
v
hex value keeps
increasing
Hope this helps anyone else that was confused like me! This website helped me a lot, you can put in any hex value and it will show both the signed and unsigned equivalent decimal value.
For signed, starting at 0, the numbers keep increasing until the largest possible decimal number signed hex can represent (2,147,483,647), then suddenly flips to the biggest negative decimal number it can represent. However, looking at it this way, the crucial part to understand is that value in hex keeps increasing, even after the decimal number it represents makes the flip.
Signed Hex to Decimal
| 00000000 = 0
| 00000001 = 1
| 00000002 = 2
| (etc...)
| 7FFFFFFD = 2,147,483,645
| 7FFFFFFE = 2,147,483,646
| 7FFFFFFF = 2,147,483,647 <--- biggest possible decimal number in signed hex
| 80000000 = -2,147,483,647 <--- Sudden flip to the biggest negative!
| 80000001 = -2,147,483,646
| 80000002 = -2,147,483,645
| (etc...)
| FFFFFFFD = -3
| FFFFFFFE = -2
| FFFFFFFF = -1
v
hex value keeps
increasing
But if it's unsigned (logical), we don't make the flip at 80000000. We just keep increasing, which means we can represent double the amount of decimal numbers. Meaning, instead of the max being 2,147,483,647, the max is now double that, 4,294,967,295.
(if you just did that math yourself and are wondering why it came out to be one less, it's because we didn't have to repeat a number on the flip, so we get one bonus number in there.)
Unsigned (Logical) Hex to Decimal
| 00000000 = 0
| 00000001 = 1
| 00000002 = 2
| (etc...)
| 7FFFFFFD = 2,147,483,645
| 7FFFFFFE = 2,147,483,646
| 7FFFFFFF = 2,147,483,647
| 80000000 = 2,147,483,648 <--- No flip, number keeps increasing!!!!!
| 80000001 = 2,147,483,649
| 80000002 = 2,147,483,650
| (etc...)
| FFFFFFFD = 4,294,967,293
| FFFFFFFE = 4,294,967,294
| FFFFFFFF = 4,294,967,295 <--- biggest possible decimal number in unsigned hex
v
hex value keeps
increasing
Hope this helps anyone else that was confused like me! This website helped me a lot, you can put in any hex value and it will show both the signed and unsigned equivalent decimal value.