# How to Convert a Hex File to Binary

Written by jo pick
• Share
• Tweet
• Share
• Pin
• Email

Hex (short for hexadecimal) and binary are numbering systems that come up in computer science all the time. Computers actually use binary numbers for everything, but binary numbers are hard for humans to read so computer memory is usually written out in hex. Binary numbers are patterns of 0s and 1s, which works out well for computers. but is really hard for humans to read. Hex numbers are the familiar digits 0 through 9 plus the letters A through F. These patterns make more sense to humans. It is easy to convert back and forth between binary and hex.

Skill level:
Moderate

## Instructions

1. 1

Understanding the relationship between hex and binary and the conversion of a hex file to binary is easy. Binary uses a base of two; decimal uses a base of ten; and hex uses a base of 16. The base determines how many digits are used in a particular numbering system. Binary uses only two digits: 0 and 1. The decimal system uses 10 digits: 0 through 9. The hex system uses 16 symbols: 0 through 9, plus A through F. Computers like to use base 2 because that means memory locations (and many other things) only need to be in two states: 0 and 1.

2. 2

Know why it is easy to convert from hex to binary and why hex preserves the underlying structure of the binary patterns and you will understand why it is easy (and desirable) to convert back and forth from hex to binary. Converting between hex and decimal works well because the numbers 2 and 16 are related in a special way. When 2 is multiplied by itself four times it becomes equal to 16. This means that one symbol of hexadecimal represents the same amount of information as four digits of binary, and this is the key to converting hex to decimal: one hex digit always represents the same four binary digits. The Hex is more compact, easier to read and still has the binary pattern easily visible beneath the hex symbols.

3. 3

Convert a hex file to a binary file one symbol at a time. Use the following transformations throughout the hex file to convert each hex symbol to four binary symbols. 0 becomes 0000,1 becomes 0001, 2 becomes 0010, 3 becomes 0011, 4 becomes 0100, 5 becomes 0101, 6 becomes 0110, 7 becomes 0111, 8 becomes 1000, 9 becomes 1001, A becomes 1010, B becomes 1011, C becomes 1100, D becomes 1101, E becomes 1110 and F becomes 1111. The binary file will have four times the number of symbols as the hex file, but will contain exactly the same information.

#### Tips and warnings

• Format your input and output files in such a way that it is easy to compare results. For example use exactly four binary lines for each hex line. It is real easy to get out of synchronisation and this will make checking easy. Look for easy patterns like 0000 or 1111 when you check.
• If you get one character off in your translation, everything from that point will be incorrect. Format the output so that it is easy to verify the results.

### Don't Miss

#### Resources

• All types
• Articles
• Slideshows
• Videos
##### Sort:
• Most relevant
• Most popular
• Most recent