# Binary to Hex Converter

## Converting Binary to Hexadecimal

Binary is the most basic language of computers. Everything, from simple text to full-length movies can be exepressed using binary. Computers use binary because it is a base 2 numbering system, in which each digit value has a value of one or zero. Thanks to the invention of the transistor, computers can represent binary numbers at an electronics level. Simple operations are implemented on the CPU and use binary values to compute.

Binary numbers are *long*, though. You need at least eight binary digits to represent a single character. This is where hexadecimal is useful, as it can represent an eight-digit binary number (more commonly referred to as a byte) using a two-digit hexadecimal number.

The process of converting from binary to hexadecimal using grouping is fairly simple. Each group of four binary digits corresponds to a single hexadecimal digit.

- Start with a given binary number, and pad it on the left with zeroes until its length is a multiple of four.
- Split up the binary number, starting from the right, into equally sized four digit chunks.
- Working from the right, convert each group into a single hexadecimal character using the table.

### Example

Converting `101111010`_{2}

to hexadecimal:

`101111010`_{2} = 000101111010_{2}

- First chunk:
`1010`_{2} = A_{16}

- Second chunk:
`0111`_{2} = 7_{16}

- Third chunk:
`0001`_{2} = 1_{16}

Thus, `101111010`_{2} = 17A_{16}

### Conversion table

Binary | Hex | | Binary | Hex |
---|

0000 | 0 | | 1000 | 8 |

0001 | 1 | 1001 | 9 |

0010 | 2 | 1010 | A |

0011 | 3 | 1011 | B |

0100 | 4 | 1100 | C |

0101 | 5 | 1101 | D |

0110 | 6 | 1110 | E |

0111 | 7 | 1111 | F |