What Is Hexadecimal

If you passed grade school, you can probably count to 10; perhaps higher? You start at 0 and count 1.. 2.. 3.. 4.. 5.. 6.. 7.. 8.. 9.. To get the next number, you start back at 0 and insert a 1 in as the second digit to get 10. Simple, right? What you are counting in is know as a base-10 number system, also called decimal, because there are 10 different numbers per digit. Before we talk about hexadecimal, we should mention a little bit about the number 0.

If I asked you to count to 4 you would probably count: 1.. 2.. 3.. 4.. However, if I asked a computer to count to 4 it would say: 0.. 1.. 2.. 3.. 4.. See the difference. When you work with computers, 0 is just as important as the other numbers. All computer counting counting starts at 0 unless it has been told otherwise. This becomes important when you deal with loops.

Now that you hopefully understand decimal and what it is, lets move to hexadecimal. Hexadecimal, also know as hex, is a base-16 numbering system. That's right, 16 different numbers per digit. So, counting in hex works like this: 0.. 1.. 2.. 3.. 4.. 5.. 6.. 7.. 8.. 9.. A.. B.. C.. D.. E.. F.. There you have it, 16 different numbers per digit. That means that we can represent and number from 0 to 15 with a 1 digit number instead of just 0 to 9 like in decimal. So what if we want to write 16 in hex? Well, it's just like writing 10 in decimal. You reset the first digit back to zero and tack on a 1 in front. So 16 in decimal is actually 10 in hex. So how do I convert between hex and decimal? Simple! On your computer go to Start > Run > calc.exe. Switch it into scientific mode. Now click the radio button that says hex, type a number in, then click the radio button that says decimal. Done. You may also perform the reverse to convert from decimal to hex. So how do I add, subtract, etc? Don't worry, the calculator does all that for you too! It also will perform bitwise operations, although bitwise operations are beyond the scope of this tutorial.

So when do I use hex? All the time in game hacking! Everything is in hex from the values in memory to the codes you will soon create! You may be wondering why the "ancient creators of the computer" decided not to keep things simple and just use decimal. While all that is history and beyond the scope of this tutorial. I will say that is has to do with machine conversion of binary (The 1s and 0s used by machine hardware) to a more "human readable" form. After all which looks more confusing: 0100 1010 or 0x4A

. BTW, The 0x is just notation to let people know that the number is in hex. 0x4A is the same as just 4A. It is good habit to prefix hex with a 0x

Bits and Bytes

Many people often use the two words interchangeably however they do not mean the same thing. A bit is a 1 or a 0 (base 2 numbering system

). When 8 bits are put together they form a byte as you can see in the example at the end of the last paragraph. Every set of 4 bits makes up 1/2 of a byte or a nibble which is 1 digit of the byte. So from the above, 0100 represents 4 and 1010 represents A. How the conversion is done is beyond the scope of this tutorial but I will show you why there are only 16 different numbers per digit in hex. To understand this you should know some basic statistics. Each bit can be only 1 of 2 different numbers and there are 4 bits per nibble. So 2x2x2x2 or 2^4 = 16. Don't worry if this does not make sense, the only thing you need to know about bits to hack is how big of a hex number they make which we will discuss next.

8 Bit hex numbers are the smallest hex numbers you will be working with during this tutorial. An 8 bit hex number is two digits and looks this 0x4A or just 4A. If you were paying attention above you should know why it is an 8 bit hex number. Because it is made up of 8 bits. Simple! Now let's see if you were really paying attention. How big of a number (in decimal) can an 8 bit hex number hold? Think about how many numbers are in a single hex digit and how many digits are in an 8 bit hex number. The answer to part 1 is 16 and the answer to part 2 is 2. So if you take 16^2, you get 256. So an 8 bit hex number can store anything from 0 - 255. But what if you need to store a larger number? Read on to find out.

16 Bit hex numbers are the next size up. They are 4 digits and can store anything from 0 - 65535. Not much else needs to be said about them.

32 Bit is the largest sized number you will deal with in your hacking. You can hold anything from 0 - 4,294,967,295! That's huge! You can get bigger then 32 bits but I doubt you will ever need to. 24 bit hex numbers are not used for game hacking in case your wondering where they are.

Endianess

This is the last important concept with hexadecimal. Endianess is also know as the "byte order". Just like the name says, "byte order" determines the order of bytes in memory. Take this 32 Bit number for example. 0xF5 43 AE 01 (I have spaced the individual bytes apart for your convenience). In a "Big-Endian" system, the number would be written as 0xF5 43 AE 01. In a "Little Endian" system, the number would be written like 0x01 AE 43 F5. See the difference? "Little-Endian" flips the byte order so the least significant byte comes first. It is very important to note however that Endianness does NOT affect individual bytes or 8 Bit hex numbers. The Wii is a "Big-Endian" system (no flipping required W00T).