Conversion Between Binary and Hexadecimal
In the GCSE Computer Science exam you could be asked why we might use hexadecimal rather than binary. The two main reasons are that:
- binary numbers can quickly get very long - even sixty-four is a seven-digit number. This means that they can be difficult to read and difficult to write - the more digits the greater the likelihood of a transcription error.
- while denary numbers are generally more concise (i.e. use fewer digits) than binary, hexadecimal numbers are often shorter still and also easier to convert to binary numbers
Below you can see a binary number and a hexadecimal number. Changing one will change the other and allow you to investigate the conversion process. You can click a binary digit to toggle it between 0 and 1. You can click a hexadecimal digit to increase its value, or right-click to decrease the value. The concatenated result and the denary equivalent will be shown at the bottom.
To convert binary numbers to hexadecimal, we group the bits into blocks of four (i.e. a nibble) and then convert each group into a single hexadecimal digit and then concatenate the resulting digits. In the exam you will usually do this with a whole byte (i.e. eight bits), but if the number of bits isn't a multiple of four then you need to group them into fours starting with the least-significant bit (i.e. on the right).
To convert hexadecimal to binary, convert each hexadecimal digit into a four-bit binary number and concatenate the results. Each binary number must have four bits - if the hexadecimal digit is less than eight then you will need to add leading zeros.