0% found this document useful (0 votes)
34 views27 pages

CT - Lecture 3 - Number Systems

Number Systems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views27 pages

CT - Lecture 3 - Number Systems

Number Systems
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

WEEK 3: NUMBER SYSTEMS

COMPUTING FOR TECHNOLOGY – FOT 1001


WEEK 3: CONTENT

Decimal, binary, octal and hexa-decimal number systems.


Number systems conversions.
Binary and non-binary fractions.
DECIMAL, BINARY, OCTAL AND
HEXADECIMAL
NUMBER SYSTEMS

 A number system is a system of representing numbers of a certain type.


Usually a number system follows a positional system and has a base.
 The value of each digit in a number system can be determined using the
digit, the position of the digit in the number and the base of the number
system (total number of digits available in the number system)
 Most common types of number systems are: decimal, binary, octal and
hexadecimal.
DECIMAL NUMBER SYSTEM
Here's the decimal number system as an example:
 digits (or symbols) allowed: 0-9
 base (or radix): 10
 the order of the digits is significant

345 is really
3 x 100 + 4 x 10 + 5 x 1
3 x 10^2 + 4 x 10^1 + 5 x 10^0
3 is the most significant symbol (it carries the most weight)
5 is the least significant symbol (it carries the least weight)
BINARY NUMBER SYSTEM

Here's the binary number system:


 digits (or symbols) allowed: 0, 1
 base (or radix): 2
 each binary digit is called a BIT
 the order of the digits is significant
 LSB (least significant bit) is the first bit from the right.
 MSB (most significant bit) is the first bit from the left.
BINARY NUMBER SYSTEM

1001 (base 2) is really

1 x 2^3 + 0 x 2^2 + 0 x 2^1 + 1 x 2^0


9 (base 10)

11000 (base 2) is really

1 x 2^4 + 1 x 2^3 + 0 x 2^2 + 0 x 2^1


+ 0 x 2^0
24 (base 10)
OCTAL NUMBER SYSTEM

Here's the octal number system: 345(base 8) is really


 digits (or symbols) allowed:
0-7 3 x 8^2 + 4 x 8^1 + 5 x 8^0
192 + 32 + 5
 base (or radix): 8 229 (base 10)
 the order of the digits is
significant 1001 (base 8) is really
 was widely used in
1 x 8^3 + 0 x 8^2 + 0 x 8^1 + 1 x 8^0
computing before 512 + 0 + 0 + 1
hexadecimal replaced it 513 (base 10)
HEXADECIMAL NUMBER SYSTEM

Here's the hexadecimal number system: Hex Decimal


0 0
 digits (or symbols) allowed: 0-9, A-F 1 1
.
 base (or radix): 16
.
 the order of the digits is significant .
9 9
 widely used in computing for shortening binary number A 10
representations B 11
C 12
 common syntax is to use “0x” as a prefix to the hex value. D 13
(e.g. 0x8d is the hexadecimal value of 8d) E 14
F 15
HEXADECIMAL NUMBER SYSTEM

A3 (base 16) is really


a x 16^1 + 3 x 16^0
160 + 3
163 (base 10)
GENERALLY…

Given an n-digit number (in weighted positional notation):


Sn-1 Sn-2 . . . S2 S1 S0

the subscript gives us a numbering of the digits.


given a base b, this is the decimal value
the summation (from i=0 to i=n-1) of S * b^i
NUMBER SYSTEMS CONVERSIONS
ANY BASE TO DECIMAL CONVERSION

Use the summation formula in the previous slide.

134 (base 5)
1 x 5^2 + 3 x 5^1 + 4 x 5^0
25 + 15 + 4
44 (base 10)
DECIMAL TO ANY BASE CONVERSION

Divide decimal values by the base until the quotient is 0. The remainders give the digits
of the value.
36 (base 10) to base 2
(binary) 14 (base 10) to base 2
(binary)
36/2 = 18 r=0 <-- lsb 14/2 = 7 r=0 <--
18/2 = 9 r=0 lsb
9/2 = 4 r=1 7/2 = 3 r=1
4/2 = 2 r=0 3/2 = 1 r=1
2/2 = 1 r=0 1/2 = 0 r=1 <--
1/2 = 0 r=1 <-- msb msb

36 (base 10) == 100100 14 (base 10) == 1110


(base 2) (base 2)
DECIMAL TO ANY BASE CONVERSION

Divide decimal values by the base until the quotient is 0. The remainders give the digits
of the value.
38 (base 10) to base 3 100 (base 10) to base 5
38/3 = 12 r=2 <-- ls 100/5 = 20 r=0
digit 20/5 = 4 r=0
12/3 = 4 r=0 4/5 = 0 r=4
4/3 = 1 r=1
1/3 = 0 r=1 <-- ms 100 (base 10) = 400 (base 5)
digit

38 (base 10) == 1102 (base


3)
BINARY TO OCTAL CONVERSION

1. group into 3's starting at least example:


significant symbol (if the number
of bits is not evenly divisible by 3, 100 010 111
then add 0's at the most significant (binary)
end) 4 2 7
2. write one octal digit for each (octal)
group
10 101 110
(binary)
2 5 6
(octal)
BINARY TO HEXADECIMAL CONVERSION

1. group into 4's starting at least


significant symbol (if the number example:
of bits is not evenly divisible by 4,
then add 0's at the most significant 1001 1110 0111 0000
end) 9 e 7 0

2. write one octal digit for each 1 1111 1010 0011


group 1 f a 3
3. the method is similar to binary to
octal conversion
OCTAL TO BINARY CONVERSION

write down the 3 bit binary code for each octal digit

example:
5 0 1
101 000 001
HEXADECIMAL TO BINARY CONVERSION

write down the 4 bit binary code for each hexadecimal digit

example:

3 9 c 8
0011 1001 1100 1000
OCTAL – BINARY REFERENCE TABLE
HEXADECIMAL – BINARY REFERENCE TABLE
HEXADECIMAL – OCTAL CONVERSION

Hexadecimal to octal conversation could be done in two steps,


1. Hex to binary
2. Binary to octal

Octal to hexadecimal conversation could be done in two steps,


3. Octal to binary
4. Binary to hexadecimal

Alternatively, this conversion could be done through the decimal number system as well.
BINARY AND NON-BINARY FRACTIONS
BINARY FRACTIONS

fn-1 fn-2 . . . f2 f1 f0 . f-1 f-2 f-3 . . .

The decimal value is calculated in the same way as for non-fractional numbers, the
exponents are now negative.
BINARY FRACTIONS TO DECIMAL CONVERSION

example:
101.001 (binary)
1 x 2^2 + 1 x 2^0 + 1 x 2^-3
4 + 1 + 1/8
5 1/8 = 5.125 (decimal)

2^-1 = .5
2^-2 = .25
2^-3 = .125
2^-4 = .0625 etc.
DECIMAL FRACTIONS TO BINARY CONVERSION

fraction fraction x 2
Consider left and right of
the decimal point .8 1.6 1 (MS)
separately. .6 1.2 1
The integer part can be
converted to binary as .2 0.4 0
before. .4 0.8 0
Use the following algorithm .8 (it must repeat from here!)
to convert the fractional
part.
.8 is .1100
NON-BINARY FRACTIONS

Same as with binary fractal conversions, only the base changes.

You might also like