← Back

Bits to Hex


Hexadecimal refers to a base-16 number system, which consists of 16 unique symbols, in contrast to the decimal number system (of 10 distinct symbols) or the binary number system (of 2 distinct symbols).

These symbols (and their corresponding binary and decimal numbers) are as follows:

	Binary  Hex.
0	0000	0
1	0001	1
2	0010	2
3	0011	3
4	0100	4
5	0101	5
6	0110	6
7	0111	7
8	1000	8
9	1001	9
10	1010	A
11	1011	B
12	1100	C
13	1101	D
14	1110	E
15	1111	F
The hexadecimal system is commonly used by programmers to describe locations in memory. Like the memory address 10011011 can be converted to hexadecimal as: 1001 1011 => 9B. Of course, it is much easier for humans to read.

Also, the conversion between hexadecimal and binary numbers is also easy after a little practice. For example, to convert a byte value from hexadecimal to binary, all that is necessary is to translate each individual hexadecimal digit into its four-bit binary equivalent.

Hexadecimal numbers are indicated by the addition of either an 0x prefix or an h suffix. For example, the hexadecimal number 0x2F5B translates to the binary number 0010 1111 0101 1011.

A common use of hexadecimal numbers is also to describe colors on web pages. Each of the three primary colors (i.e., red, green and blue) is represented by two hexadecimal digits to create 255 possible values, thus resulting in more than 16 million possible colors. For example, the HTML (hypertext markup language) code telling a browser to render the background color of a web page as red is <body bgcolor="#FF0000"> and that telling it to render the page as white is <bgcolor="#FFFFFF">.


This was Hexadecimal, and next, we will see 'base64' - a text-to-binary encoding scheme that converts binary data to an ASCII-like string, using 64 characters.
Bye till then.

Post-13 Ended.