0% found this document useful (0 votes)
68 views

Hexadecimal System

The hexadecimal system uses base-16 numerals to concisely represent values for computer processing and display of color. It uses 16 symbol values from 0-9 and A-F to express each digit, allowing more values to be represented with fewer bits than binary. This makes hexadecimal more compact and human-readable than binary for applications like MAC addresses, memory addresses, and web colors.

Uploaded by

Muse Mania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Hexadecimal System

The hexadecimal system uses base-16 numerals to concisely represent values for computer processing and display of color. It uses 16 symbol values from 0-9 and A-F to express each digit, allowing more values to be represented with fewer bits than binary. This makes hexadecimal more compact and human-readable than binary for applications like MAC addresses, memory addresses, and web colors.

Uploaded by

Muse Mania
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Hexadecimal System

 The HEXADECIMAL SYSTEM is very closely related to the binary


system. Hexadecimal (sometimes referred to as simply ‘hex’) is a
base 16 system and therefore needs to use 16 different ‘values’ to
represent each digit.

 Because it is a system based on 16 different digits, the numbers 0 to


9 and the letters A to F are used to represent each hexadecimal
(hex) digit. (A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.)

 Using the same method as denary and binary, this gives the
headings of 160, 161 , 162, 163 and so on.
 The typical headings for a hexadecimal number with five digits
would be:

 Since 16 = 𝟐𝟒 this means that FOUR binary digits are equivalent to


each hexadecimal digit.

 The following table summarises the link between denary, binary,


octal and hexadecimal
Numeral Systems Conversion Table
 The main reason why we use hexadecimal numbers is because it 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.

 Let’s look at an example, using a byte.

 Bytes are typically 8 bits, and can store the values 0 – 255 (0000 0000 –
1111 1111 in binary).

 For people, expressing numbers in binary is not convenient. You are not
going to turn around to your classmate and tell him that your phone
number is 101 101 101 001 010 001 010 for obvious reasons.

 Imagine having to try and work with that on a daily basis. So a more
convenient expression is needed for the humans.
 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 is easier to express a binary value to another person as “A” than it


is to express it as “1010”.

 This way you can simply use 2 hex values to represent a byte and
have it work cleanly.
 So if you have a hex value of “CE”, you can easily determine that
(12*161 ) + (14*160) = 206 in decimal, and can easily write it out in
binary as 1100 1110.

 Trying to convert from binary would require that you know what
each place holder represents, and add all the values together (128 +
64 + 8 + 4 + 2 = 206).

 It is much easier to work with binary through hex than any other
base system.
1. Binary to Hexadecimal

2. Hexadecimal to Binary

3. Hexadecimal to Decimal

4. Decimal to Hexadecimal
 Converting from binary to hexadecimal is a fairly easy process.

 Starting from the right and moving left, split the binary number into
groups of 4 bits.

 If the last group has less than 4 bits, then simply fill in with 0s from
the left.

 Take each group of 4 bits and convert it into the equivalent


hexadecimal digit.
 Let’s assume we have a binary number of 01010111 which needs to
be converted to Hexadecimal.

8 4 2 1 8 4 2 1
0 1 0 1 0 1 1 1
0x8 1x4 0x2 1x1 0x8 1x4 1x2 1x1
0 4 0 1 0 4 2 1
0+4+0+1=5 0+4+2+1=7
5 7

 Hence the Hexadecimal equivalent is (57)16


 Convert the binary number of 1 1 1 0 0 0 0 1 to Hexadecimal.

8 4 2 1 8 4 2 1
1 1 1 0 0 0 0 1
1x8 1x4 1x2 0x1 0x8 0x4 0x2 1x1
8 4 2 0 0 0 0 1
8+4+2+0=14 0+0+0+1=1
14 -> E 1

 Hence the Hexadecimal equivalent is (𝐸1)16


101111100001

 First split this up into groups of 4 bits:

1011 1110 0001

 Then, using the above Numeral Systems Conversion Table,


find the equivalent hexadecimal digits:

(𝐵𝐸1)16
10000111111101

 First split this up into groups of 4 bits:


10 0001 1111 1101

 The left group only contains 2 bits, so add in two 0s:


0010 0001 1111 1101

 Now using the above Numeral Systems Conversion Table, find


the equivalent hexadecimal digits:
(21𝐹𝐷)16
 Converting from hexadecimal to binary is also very straightforward.

 Using the data from the Numeral Systems Conversion Table, simply
take each hexadecimal digit and write down the 4-bit code which
corresponds to the digit.
 Convert (45𝐴)16 to binary

 Using the above Numeral Systems Conversion Table, find the 4-bit
code for each digit:
0100 0101 1010

 Put the groups together to form the binary number:


(0 1 0 0 0 1 0 1 1 0 1 0)2
 Convert (𝐵𝐹08)16 to binary

 Again just use the above Numeral Systems Conversion Table

1011 1111 0000 1000

 Then put all the digits together:


(1 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 )2
 To convert a hexadecimal number to denary is fairly
straightforward.

 Take each hexadecimal digit and multiply it by its value. Add


the totals together to obtain the denary value.
 Convert (45𝐴)16 to decimal

 First multiply each digit by its value:

Add the totals together:

Answer = (1114)10
 Convert (𝐶8𝐹)16 to decimal

 First multiply each digit by its value:

Add the totals together:


Answer = (3215)10
 To convert from denary to hexadecimal is a little more
difficult.

 As with the conversion from binary to denary, there are two


very similar methods that can be used. Again, the first
method is more methodical and involves repetitive division
and the second method is ‘trial and error’.
 This method involves successive division by 16. The
remainders are then read from BOTTOM to TOP to give the
hexadecimal value.
 Consider the conversion of the denary number, 2004, into
hexadecimal. This method involves placing hexadecimal
digits in the appropriate position so that the total equates to
2004

 A quick check shows that: (7 × 256) + (13 × 16) + (4 × 1)


gives 2004.
 Along with the advances in Microcomputers, "the Internet"
has experienced many changes as well.

 A code still used by "Web browsers" today had been invented


to transfer information from servers to terminals in a way that
made the Internet a much more effective tool for research.

 That code is called "Hyper-Text Markup Language" (or HTML)


and it soon included a method which could theoretically
reproduce background and text with a total of 16,777,216
different colors.
 The hardware available today has already advanced way beyond
that limit. The main reason was a push to display pictures "in
living color;" now a common reality.

 And one of the first things a new computer user should always
do is make sure their display can be set to what's called "24-bit"
or "True Color" (for those 16-million plus possible colors).

 As a matter of fact, almost every video card today has the


capacity to reproduce what's called "32-bit" color.

 But all those extra bits are not used for increasing the number of
colors! Why? Well, since the human eye is only capable of
distinguishing something like 7 million or so different colors that
would be a real waste of technology!
 Hexadecimal color values are supported in all major
browsers.

 A hexadecimal color is specified with:

 #RRGGBB, where the RR (red), GG (green) and BB (blue)


hexadecimal integers specify the components of the
color.

 All values must be between 00 and FF.

 For example, the #0000FF value is rendered as blue,


because the blue component is set to its highest value
(FF) and the others are set to the lowest value (00).
 http://www.html.am/html-generators/text-
color-generator.cfm
 A typical MAC address looks something like this: af-14-b3-
c2-14-45

 You may be wondering why we've got letters and numbers in


this address.

 MAC addresses are expressed in hexadecimal, which gives us


the ability to express more values with the same number of
bits.

 Theoretically, every single NIC in the world should have a


totally unique MAC address, and the only way to do this is to
express MAC addresses in hexadecimal.
 In 8 bit PC register, the largest number is 1111 1111 which has 8
bits. At the same time the 2 digit hexadecimal number for 1111
1111 is ‘FF’.

 Do you see how skillfully it is used? Don’t forget that computers


process 8-digit binary numbers.

 For the convenient use of programmer in Assembly language, it is


easy to manipulate hexadecimal numbers rather than binary
numbers.

 Using true machine code (which uses binary) is very cumbersome


and it takes a long time to key in the values. It is also very easy to
mistype the digits in a ‘sea of 1s and 0s’. Here is a simple example:

You might also like