Hexadecimal

From Data Crystal
Jump to: navigation, search

Hexadecimal or base 16 is a number system which uses the numerals 0-9 and letters A-F or a-f to represent digits. It is commonly used in ROM hacking, since it provides an easy way to write the binary numbers used by computers. Often representing numbers as decimal is either unwieldy and meaningless in the case of pointers or obscures the meaning of data stored in bits. For example, a byte could be used as eight true/false flags, but reading the same byte as a decimal number would be meaningless.

More non-ROM hacking specific information can be found at Wikipedia's hexadecimal article.

Working with Hexadecimal Numbers

Converting between Hex and Binary

To convert from binary to hex simply start from the right and seperate the binary number into nibbles (groups of four bits) then simply change each nibble to its respective hex digit. To convert from hex to binary just change each hex digit to its respective nibble. Anyone who plans to spend a lot of time working with machine code or assembly should dedicate the below table to memory.

Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111

Converting Decimal values to Hexadecimal values

Converting Hexadecimal values to Decimal Values