hexadecimal addition, what does it mean to “add 0x1000000 – 1” for example?

429 viewsMathematicsOther

hexadecimal addition, what does it mean to “add 0x1000000 – 1” for example?

In: Mathematics

4 Answers

Anonymous 0 Comments

You know how you count in decimal, when you get to 9 you add 1 to the next place over start back at 0. With hexadecimal, you keep counting A B C D E F before carrying over to the next place and starting back at zero.

It’s just a more convenient way of displaying data for lots of computer based operations. The maximum value an unsigned integer can store is just “F” in every place.
>add 0x1000000 – 1

Lets say a computer is adding two four byte signed integers, that would be 0x01000000, and -1 in decimal would be represented as 0xFFFFFFFF. (in computers, negative numbers are represented in twos complement). The way this works out is that you can still add the numbers normally.

01 00 00 00
FF FF FF FF
——————————-
1 00 FF FF FF
The 1 at the left sets the carry flag, but in this case that’s just ignored, leaving a result of 0x00FFFFFF.

Going back the other way, if you add 1 to the 0x00FFFFFF, you carry several times and end up with 0x01000000.

You are viewing 1 out of 4 answers, click here to view all answers.