Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

The Number System CS

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

The Number System

BY: Mr Hussain KORIR

Contact:0714980988
The Number System
Number systems are the techniques to represent numbers in the computer system.
 A set of values used to represent different quantities is known as Number System.
 The digital computer represents all kinds of data and information in binary numbers.
It includes audio, graphics, video, text and numbers.
 The number of digits used in a number system is called its base or radix.
 The base is written after the number as subscript such as (10101)2 ,(28)10
 Since computers contain millions and millions of tiny ‘switches’, which must be in
the ON or OFF position, they can be represented by the binary system.
 A switch in the ON position is represented by 1; a switch in the OFF position is
represented by 0.
Types of
Number System

Binary Numbers
(base 2)

Denary/Decimal Hexadecimal
Octal Numbers
numbers Numbers
(Base 8)
(base 10) (Base 16)
Binary Number System
 Binary number system uses only two digits that are 0 and 1.
 All the computers and electronic devices are using it for their internal processing.
 The base of binary number system is 2, as it has only two digits.
 Binary numbers are also called the base 2 number system. It can be written as (101010)2.

Octal number system


 Octal number system has eight digits from 0 to 7.
 Since 8 digits are used, it is also called the base 8 number system.
 Every number (value) represents with 0,1,2,3,4,5,6 and 7 in this number system.
 The base of octal number system is 8 because it has only 8 digits. It can be written as (76401)8
Decimal number system
This is the most popular number system for user. Our everyday counting system is called denary (or decimal). Denary is a base-10
number system.
 Decimal number system has only ten(10) digits from 0 to 9.
 Every number (value) represents with 0,1,2,3,4,5,6, 7,8 and 9.
 The base of decimal number system is 10 because it has only 10 digits. So, it is also called the base 10 number system. It can be written
as (9801)10.

 Hexadecimal number system


 A Hexadecimal number system has 16 alphanumeric values from 0 to 9 and A to F.
 Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F.
 The base of hexadecimal number system is 16 because it has 16 alphanumeric values.
 It is also called base16 number system.
 In this number system , the value for A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15. It can be written as (961)16, (DAF1)16, etc .
Conversion Table
Converting Binary(Base2) to Denary(Base 10)
Computers use switches to store data and these switches can be in one of
two states: on or off.
Because of this we need to convert all data and instructions into binary,
which can represent on or off using the two digits 0 and 1 (Zero = Off)
(One=On)

■ Each stored binary digit is called a bit (binary digit). Example 0


and 1(1 is a bit) (0 is a bit) (10= 2bits)
■ A group of 8 bits is called a byte. example 11110000
■ Half a byte, 4 bits, is called a nibble . Example: 1111
128 64 32 16 8 4 2 1
MSB LSB 1000 100 10 1

>>The column values are ten times larger than the previous value as we move from right to left; that is, the
‘hundreds’ are ten times bigger than ‘tens’ and ‘tens’ are ten times bigger than ‘ones’.
>>In binary we just have the two symbols or values, 0 and 1. This means that in the binary number system each
column heading is twice as big as the previous one as we move from right to left
The column headings in binary, from right to left, are ‘ones’, ‘twos’, ‘fours’, ‘eights’ and so on.
The leftmost digit in a binary number is called the most significant bit (MSB) and the
rightmost digit the least significant bit (LSB).
In an 8-bit number, the MSB has decimal value of 128 and the LSB has decimal value of 1.
How to convert denary numbers
into 8-bit binary numbers and vice versa
Method1
To convert denary numbers into binary, we use the binary column heading values from the table.
 We decide whether each column heading value, starting at the left-hand side, is smaller than or equal to our decimal
number.
 We record 0 if it is not smaller and then compare it with the next column value.
 If it is smaller than or equal to, we record 1 in the table,
 subtract the number and work out the remainder.
 We take that remainder and then check if it is smaller than the next column value, and repeat the process above. We
continue this process until we are left with the right-hand ‘1’ column .
Method 2
This method involves successive division by 2.
Start with the denary number, 142, and divide it by 2.
Write the result of the division including the remainder (even if it is 0)
under the 142 (that is, 142 ÷ 2 = 71 remainder 0);
Then divide again by 2 (that is,71 ÷ 2 = 35 remainder 1) and keep dividing until the result is zero.
Finally write down all the remainders in reverse order:

If we want to show this as an 8-bit binary number (as shown in Method 1), we now simply
add two 0’s from the left-hand side to give the result: 0 0 1 1 1 0 1 1.
The hexadecimal system
The hexadecimal number 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 ‘digits’ to
represent each value.
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 in hex = 10 in denary, B = 11, C = 12, D = 13, E = 14 and F = 15.
Using the same method as for denary and binary, this gives the headings 16 0, 161, 162, 163, and so on.
The typical headings for a hexadecimal number with five
digits would be: Example :2 1 F 3 A
65536(164) 4096(163) 256(162) 16(161) 1(160)

2 1 F 3 A
Converting from binary to hexadecimal and from
hexadecimal to binary
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 using Table

Example 1
Convert 1 0 1 1 1 1 1 0 0 0 0 1 to Hexadecimal
First split this up into groups of 4 bits:
1011 1110 0001
Find the value of each grouped binary digits in decimal/denary
1011=11 1110=14 00001=1
Then, using Table <find the equivalent hexadecimal digits of
11, 14 and 1
Answer :11=B , E=14 and 1=1
1011,1110,0001=BE1
Converting from hexadecimal to denary and
from denary to hexadecimal
• To convert hexadecimal numbers into denary involves the value headings of each hexadecimal
digit; that is, 4096, 256, 16 and 1.
• Take each of the hexadecimal digits and multiply it by the heading values.
• Add all the resultant totals together to give the denary number. Remember that the hex digits A → F
need to be first converted to the values 10 → 15 before carrying out the multiplication.
EXAMPLE
A typical example of hex is 2 1 F 3 A
24 13 F2 31 A0

2 1 15 3 10

Example 2
Convert 1B2C in to denary
Converting Denary to Hexadecimal
To convert decimal numbers to hexadecimal:
● We check if 16 will divide into the number.
● If it does, we write down how many times using the correct hexadecimal symbol in the 16s
column.
● We then convert the remainder into its hexadecimal symbol and write it in the 1s column.
Convert 189 in decimal to hexadecimal. Convert 125 to hexadecimal
189/16=11(189-176=13) rem
11 13
B D
189= BD
Why do we use hexadecimal?
We learned that the computer processes all data in binary form. Binary numbers are very useful
in computer science, but they have disadvantages:
• It is hard for people to read and understand binary numbers.
• When you write a binary number it is easy to make a mistake.
• It is hard to spot and fix errors in binary numbers.
• Writing a binary number takes a lot of space.
People wanted numbers that were easier to understand and work with. Denary notation wasn't
suitable because converting binary to denary is difficult.
The hexadecimal notation was chosen for these reasons:
• It is very easy to turn hexadecimal into binary.
• It is very easy to turn binary into hexadecimal.
• Hexadecimal is much easier to read than binary.
• Hexadecimal numbers take up much less space than binary numbers.
Use of the hexadecimal system
• As we have seen, a computer can only work with binary data. Whilst computer scientists can work with binary, they find
hexadecimal to be more convenient to use.
• This is because one hex digit represents four binary digits.
• A complex binary number, such as 1101001010101111 can be written in hex as D2AF.
• The hex number is far easier for humans to remember, copy and work with.

There are four Main Uses of Hexadecimal Numbers


» used to show error codes
»used in MAC addresses
» used in ipv6 addresses
» used in HTML colour codes
Error codes
Error codes are often shown as hexadecimal values. These numbers refer to the memory location of the error and are
usually automatically generated by the computer. The programmer needs to know how to interpret the hexadecimal
error codes.
Media Access Control (MAC) addresses
Media Access Control (MAC) address refers to a number which uniquely identifies a device on a network. The MAC
address refers to the network interface card (NIC) which is part of the device.
The MAC address is rarely changed so that a particular device can always be identified no matter where it is.
A MAC address is usually made up of 48 bits which are shown as 6 groups of two hexadecimal digits (although 64-bit
addresses also exist):
NN – NN – NN – DD – DD – DD
or
NN:NN:NN:DD:DD:DD
where the first half (NN – NN – NN) is the identity number of the manufacturer of the device and the second half (DD –
DD – DD) is the serial number of the device.
For example:
00 – 1C – B3 – 4F – 25 – FE is the MAC address of a device produced by the Apple Corporation (code: 001CB3) with a
serial number of: 4F25FE. Very often lowercase hexadecimal letters are used in the MAC address: 00-1c-b3-4f-25-fe. Other
manufacturer identification numbers include:
Internet Protocol (IP) addresses
Each device connected to a network is given an address known as the Internet Protocol (IP) address.
An IPv4 address is a 32-bit number written in denary or hexadecimal form: e.g. 109.108.158.1 (or 77.76.9e.01 in hex). IPv4
has recently been improved upon by the adoption of IPv6. An IPv6 address is a 128-bit number broken down into 16-bit
chunks, represented by a hexadecimal number.
For example:
a8fb:7a88:fff0:0fff:3d21:2085:66fb:f0fa
Note IPv6 uses a colon (:) rather than a decimal point (.) as used in IPv4.
Hyper Text Mark-up Language (HTML) colour codes
Hyper Text Mark-up Language (HTML) is used when writing and developing web pages. HTML isn’t a programming
language but is simply a mark-up language. A mark-up language is used in the processing, definition and presentation
of text (for example, specifying the colour of the text).
HTML uses <tags> which are used to bracket a piece of text for example, <h1> and </h1> surround a top-level heading.
Whatever is between the two tags has been defined as heading level 1. Here is a short example of HTML code:
HTML is often used to represent colours of text on the computer screen. All colours can be made up of different
combinations of the three primary colours (red, green and blue).
This means different hexadecimal values represent different colours. For example:
» # FF 00 00 represents primary colour red
» # 00 FF 00 represents primary colour green
» # 00 00 FF represents primary colour blue
» # FF 00 FF represents fuchsia
» # FF 80 00 represents orange
» # B1 89 04 represents a tan colour,

You might also like