In: Computer Science
Why are computer addresses described with hexadecimal notation? Why isn't the binary number system used? What is BCD?
The main reason why we use hexadecimal numbers is because it provides a more human-friendly representation and is much easier to express binary number representations in hex than it is in any other base number system.
Computers do not actually work in hex.
Lets take an example, using a byte.
1 Byte = 8 bits. It can store the values from 0 to 255 (0000 0000 to 1111 1111 in binary). Each hexadecimal digit represents four binary digits, also called Nibble. (1 Byte = 2 Nibbles)
For example, a single byte can have values ranging from 0000 0000 to 1111 1111 in binary form and can be easily represented as 00 to FF in hexadecimal.
Expressing numbers in binary is not easy for us. You can not tell your friend that my mobile number is 1001 1111 1010 0101. You cannot use these type of numbers daily for 'n' number of contacts. Thus, we need more easy expression.
Since a byte is 8 bits, it makes sense to divide that up into two groups, the top 4 bits and the low 4 bits. Since 4 bits gives you the possible range from 0 – 15, a base 16 system is easier to work with, especially if you are only familiar with alphanumeric characters.
It’s easier to express a binary value to another person as “B” then it is to express it as “1011”. This way I can simple use 2 hex values to represent a byte and have it work cleanly.I only need to memorize the multiplication tables up to 15. So if I have a hex value of EC, I can easily determine that 14 * 12 = 206 in decimal, and can easily write it out in binary as 1100 1110. Trying to convert from binary would require me to know what each place holder represents, and add all the values together (128 + 64 + 8 + 4 + 2 = 206). It’s much easier to work with binary through hex than any other base system.
There are several uses for hexadecimals in computing:
1. HTML / CSS Colour Codes
Hexadecimal numbers are used to represent colours within HTML or CSS.
The 6 digit hex colour code should be considered in three parts.
By changing the intensities of red, green and blue, we can create almost any colour.
E.g. orange can be represented as #FFA500, which is (255 red, 165 green, 0 blue). Visit hexinvaders.com to see this in action.
2. MAC Addresses
A Media Access Control (MAC) address is a number which uniquely identifies a device on the internet. It relates to the network interface card (NIC) inside of the device.
e.g. B4-CD-C7-4A-8B-D2
Expressing MAC addresses in hexadecimal format makes them easier to read and work with.
3.Assembly Code and Memory Dumps
Hexadecimals have advantage over binary due to:
Finally