What is hexadecimal?
The hexadecimal number system is base sixteen which means that there are sixteen unique symbols used as digits. Recall that the decimal number system had ten symbols. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and the binary number system had two 0 and 1. The symbols used in the hexadecimal number system are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F and are used to represent number values of 0 through 15 respectively. This means that some of the numbers is the hexadecimal number system will look like words.
More on binary and hex conversion
Hexadecimal numbers are widely used by programmers for notation purposes. Denoting something in binary is wired and tough to understand, that’s why they developed its alternative (HEX), you might think why not decimals because hexadecimal take less space, you can see it in given example.
Binary: 0110 1111 0110 1011
Each hexadecimal digit represents four binary digits, also called Nibble (1 Byte = 2 Nibbles). Given table indicates the binary numbers associated with each hexadecimal digit.
To convert a hexadecimal number to binary, simply replace each hex digit with the four bits from the table above. For example, to convert the hexadecimal number 746F to binary, the process would be:
The binary equivalent of 746F is 01110100 01101111.
Likewise, to convert a binary number to a hexadecimal number. Simply start at the right (low order) side of the number and group the bits into parcels of four, and then convert each set of four bits to a hex by using given table. For example convert the binary number 01101100 to hexadecimal.
The hexadecimal equivalent of 01101100 is 6C
You can see its easy to represent a much greater magnitude of numbers with few symbols, and the price we pay is small because the conversions are so trivial.
Hex encoding usage
Some common examples are – Ip addresses, color codes,and mac addresses etc. Mainly used because it provides a more human-friendly representation.
The main one – for encoding, some channel works on (ASCII only) scheme one example of such channel is (URL), so to bypass them we need encoding schemes like hex and base64. Usually, they convert Non-ASCII to ASCII by this, they can be easily passed through (ASCII only) channel.
Base64 vs Hex encoding
Both scheme act same, both convert non ASCII characters to ASCII ones. But hex take more space, because it make a pair of 4 bits and replace it with single character (let’s take 24 bits, hex replace it with 6 character). While base64 form a pair of 6 bits and replace it with single character (24 bits means, base64 replace it with 4 characters), in terms of small sizing base64 rocks, and due to this used alot for transmission.