The shortcut: groups of four bits
Hexadecimal, or hex, is base 16. Because 16 is 2 to the power 4, every hex digit stands for exactly four binary digits. That means you can convert without any arithmetic: split the bits into groups of four, starting from the right, and replace each group with its hex digit.
11010110
1101 0110
D 6 = D6If the number of bits is not a multiple of four, add zeros on the left. For example, 101 becomes 0101, which is 5.
Hex digits
Hex uses the digits 0 to 9 and then the letters A to F for the values 10 to 15. So 1010 is A, 1111 is F, and 1100 is C. The table at the bottom lists all sixteen.
Another example
The 16 bits 1011 1100 1111 0000 give the hex number BCF0.
Why hex is used
- Colors in web design, such as #FF8800.
- Memory addresses and machine code.
- Network addresses, such as the six pairs in a MAC address.
- Dumps of file bytes, where one byte is two hex digits.
Options
Choose upper or lower case letters, and add the 0x prefix that most programming languages use. Spaces and underscores in your binary number are ignored, so you can paste grouped bits. Paste a list to convert many numbers at once.
To go the other way, use hex to binary. For decimal, try binary to decimal. New to the idea? Read the guide to binary numbers.