Hexadecimal Addresses in C++


By default, C++ prints addresses in hexadecimal (base 16) to save space. Hexadecimal uses the numeric digits 0 through 9 and the letters 'a' through 'f' to represent the numeric values 10 through 15). Each hex digit is directly equivalent to 4 bits.

Decimal Hexadecimal Binary Decimal Hexadecimal Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 a 1010
3 3 0011 11 b 1011
4 4 0100 12 c 1100
5 5 0101 13 d 1101
6 6 0110 14 e 1110
7 7 0111 15 f 1111

C++ precedes a hexadecimal value that it prints with the characters "0x" to make it clear that the value is in base 16.

As a C++ programmer, you typically will not need to be able to convert hexadecimal numbers to binary or decimal (or vice versa) or do math in hexadecimal by hand. Both Windows and macOS have calculator apps that can be used to do those things if necessary. What you should be able to do is the following: