0% found this document useful (0 votes)
14 views68 pages

Understanding Number Systems and Conversions

The document provides an overview of number systems, including binary, octal, decimal, and hexadecimal, along with their conversions and representations in computing. It explains how data is stored in binary and details the process of converting between different number systems. Additionally, it includes exercises for practicing conversions and arithmetic operations in binary.

Uploaded by

Sinenhlanhla
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)
14 views68 pages

Understanding Number Systems and Conversions

The document provides an overview of number systems, including binary, octal, decimal, and hexadecimal, along with their conversions and representations in computing. It explains how data is stored in binary and details the process of converting between different number systems. Additionally, it includes exercises for practicing conversions and arithmetic operations in binary.

Uploaded by

Sinenhlanhla
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

Number Systems

Learning Outcomes: Module 1

• Number systems
• Conversions
Number Systems
• A Number System is a way to represent numbers. i.e., a
set of values to represent quantity.
• For instance: the number of people attending a class,
number of modules taken by each student.
• We are used to using the base-10 number system
(normal counting), which is also called decimal. Other
common number systems include base-16
(hexadecimal), base-8 (octal), and base-2 (binary).
Data Representation
• How is data stored in a computer?
• Stored and processed in binary digits
• Binary digits are ( 0s and 1s)
• BIT – Smallest unit of data in a computer. BITS are combined
into GROUPS to form numbers, characters & letters.
• When 8 bits combined together they form 1 BYTE
• BYTE – Unit to measure information storage in a computer
• 1 BYTE represent 1 CHARACTER, whereas half a byte is called
a Nibble
• Question: How many bits make up a nibble?
Data Representation (cont.)
• Notations used in digital systems:
• 4 bits = Nibble
• 8 bits = Byte
• 16 bits = Word
• 32 bits = Double word
• 64 bits = Quad Word (or paragraph)
Types of Common Number
Systems
• Binary Number Systems (Base-2)
• Octal Number Systems (Base-8)
• Decimal Number Systems (Base-10)
• Hexadecimal Number Systems (Base-16)
Binary Number System
• A Binary number system has only two digits that are 0 and
1. Every number (value) represents with 0 and 1 in this
number system. The base of binary number system is 2,
because it has only two digits.
• Includes binary digits ( 0,1)
• Consists of only 2 digits/numbers
• Therefore, it uses base 2 during calculations (number
conversions)
• In digital terms
• 1 means ON,
• 0 means OFF
Converting Binary to Decimal
• Steps on how to Convert Binary to Decimal & vice versa
• Example: Binary number (1101)2 to a decimal
number
• Step 1: Write the binary number in a row, separating
the
Numb digits into columns
er
1 1 0 1

• Step
Number 2: Decide whether each digit placeholder is "ON"
1 1 0 1
or
ON/ "OFF."
OFF ON ON OFF ON
Converting Binary to Decimal
(cont.)
• Steps on how to Convert Binary to Decimal & vice versa
• Example: Binary number (1101)2 to a decimal
number
• Step 3: Write the exponential expressions (Exponents -
Right
Number
towards
1
your1left) 0 1

ON/OFF ON ON OFF ON
Exponential
Expression 1*23 1*22 0*21 1*20

• Answer = (13)10
Converting Binary to Decimal
(cont.)
• To convert a binary number to its decimal version use the
following Method.
• Convert the binary number 11111111 to decimal
• Write out the exponential form of the number:
EXPONENTIAL
27 26 25 24 23 22 21 20
EXPRESSION
12
VALUE
8 64 32 16 8 4 2 1

BITS
1 1 1 1 1 1 1 1

• The final result is as follows:


• 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Converting Binary to Decimal
(cont.)
• Notice that where a 1 occurs the decimal value is
added. If there is a 0 then no value is added.
• Binary System – Example:
• Convert (11110101 , 10) to decimal
• 1x27 + 1x26 + 1x25 + 1x24+ 0x23 + 1x22 + 0x21 + 1x20 ,
1x2-1 + 0x2-2
• 128+ 64 + 32 + 64 + 0 + 4 + 0 + 1 , 1 x ½ +
0x¼
• 245 , 0.5 + 0
• Answer = (245,5)10
Exercise!!!
• Convert the following numbers in binary into decimal:
A. (1011)2
B. (1001)2
C. (11010100)2
D. (11001100)2
E. (10100,11)2
F. (101011,011)2
G. (111,100)2
H. (11011,1)2
I. (1010110,11)2
J. (1011,101)2
Octal Number System
• Octal number system has only eight (8) digits from 0 to
7. 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.
• Includes numbers from 0 to 7 (0,1,2,3,4,5,6,7)
• Consists of only 8 digits/numbers
• Therefore, it uses base 8 during calculations (number
conversions)
• Has 3 bit in Octal table
Octal Number System (cont.)
• To convert a binary number to OCTAL write down the
binary
• The Octal system TABLE (counting in Octal is as
Binary Octal
follows):
000 0
001 1
010 2
011 3
100 4
101 5
110 6
Octal Number System (cont.)
• Converting from binary to octal requires grouping the bits in pairs of 3
bits, from right to left.
• For example: Convert (111101110)2 to octal
• Group in pairs of 3 bits from right to left:

111 101 110


7 5 6

• Answer: (756)8
• If a pair does not have enough bits, add zero(s) (0) in front of the bit
to complete the 3 bits. For example, (1101110)2 is grouped as: (001)
=> 1, (101) => 5, and (110) => 6. Therefore, the answer is (156) 8
Exercise!!!
• Convert the following binary to octal:
A. 10111101
B. 110111010
C. 110001010
D. 101101011
Decimal 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 in this number system. The base
of decimal number system is 10, because it has only 10
digits.
• Includes numbers from 0 to 9 (0,1,2,3,4,5,6,7,8,9)
• Consists of only 10 digits/numbers
• Therefore, it uses Base 10
Converting Decimal to Binary
• Convert (13)10 to binary
Decimal Base Remainder
13 2 1
6 2 0
3 2 1
1 2 1
0

• Start from the bottom


• Answer = (1101)2
Converting Decimal to Binary
(cont.)
• Convert (36,25)10 to binary. (36,25)10 = (36)10 + (0,25)10
• First convert (36)10, followed by the conversion of (0,25)10. Thereafter, combine.
Decimal Base Remainder
36 2 0
18 2 0
9 2 1
4 2 0
2 2 0
1 2 1
0

• Start from the bottom


• Answer = (100100)2
Converting Decimal to Binary
(cont.)
• Convert (0,25)10 to binary

Decimal Base Remainder


0,25 2 0
0,5 2 1
1,0

• Start from the top


• Answer = (01)2
• (36)10 = (100100)2 and (0,25)10 = (01)2
• Combined, the answer is (100100,01)2
Exercise!!!
• Convert the following decimal numbers to binary:
A. (18)10
B. (42)10
C. (60)10
D. (25)10
E. (109)10
F. (255,25)10
G. (105,5)10
H. (800,625)10
• Expected Answers: A. (10010)2, B. (101010)2, C. ????,
D.????, E. ????
Converting Octal to Binary
• Convert (41)8 to binary
• Step 1: First convert (41)8 to its equivalent
decimal by multiplying by the base exponential
expression:
• Split the numbers and multiply by 8
• 4 x 81 + 1 x 8 0
• 4x8+1x1
• 32 + 1 = (33)10
• Therefore, (41)8 is equivalent to (33)10
Converting Octal to Binary
(cont.)
• Step 2: Then convert the equivalent decimal number
(33)10 to binary:
Decimal Base Remainder
33 2 1
16 2 0
8 2 0
4 2 0
2 2 0
1 2 1
0

• Therefore, (41)8 = (33)10 = (100001)2


Converting Decimal to Octal
(cont.)
• Convert the decimal number (33)10 back to the octal
number (41)8
• Rule: divide the decimal number by the base you wish
to convert to (base 8) Base
Decimal Remainder
33 8 1
4 8 4
0

• Therefore, (33)10 = (41)8


Exercise!!!
• Convert the following octal numbers to binary:
A. 108
B. 55
C. 752
D. 154
Exercise!!!
• Convert the following octal numbers to decimal (Rule:
Split the numbers and multiply by 8):
A. (222)8
B. (245)8

• Convert the following decimal number to octal (Rule:


divide the whole number by 8):
A. (64)10
B. (72)10
C. (126)10
Hexadecimal Number System
• A Hexadecimal number system has sixteen (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
in this number system.
• The base of hexadecimal number system is 16, because it
has 16 alphanumeric values. Here A is 10, B is 11, C is 12,
D is 13, E is 14 and F is 15.
• Includes numbers from 0 to 9 and characters from A to F
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
• Uses Base 16
Hexadecimal Number System
(cont.)
• Convert (67)10 to hexadecimal:
• Step 1: Convert the decimal number to binary
Decimal Base Remainder
67 2 1
33 2 1
16 2 0
8 2 0
4 2 0
2 2 0
1 2 1
0
Hexadecimal Number System
(cont.)
• (67)10 = (1000011)2
• Step 2: Converting from binary to hexadecimal requires
grouping the bits in pairs of 4 bits, from right to left.
0100 0011
4 3

• Therefore, (67)10 = (1000011)2 = (43)16


Exercise!!!
• Convert the following decimal number to hexadecimal:
A. (620)10
B. (1124)10
C. (1010)10
D. (825)10
E. (246)10
Binary Arithmetic
Binary Addition
• We are reminded that the computer can only use binary
numbers.
• We need to work out how to do arithmetic with just
binary numbers.
• Since there are only 2 digits available in binary the
addition table is as follows:
• 0 + 0 = 0
• 0 + 1 = 1
• 1 + 0 = 1
• 1 + 1 = 10 (with a carry of one to the next column to the left)
Binary Addition (cont.)
Rule 1 Rule 2 Rule 3 Rule 4
0 0 1 1
+ 0 + 1 + 0 + 1
0 1 1 10
Binary Addition (cont.)
• Example:
Carry 0 0 0
1 0 1 0
+ 0 1 0 1
ANS = 1 1 1 1

Carry 0 0 1
1 0 1+
0 1
+ 0 1 0 1
ANS = 1 1 1 0
Binary Addition (cont.)
• Exercise:
Carry ? ? ?
1 0 1 1
+ 0 0 0 1
ANS = ? ? ? ?
Binary Subtraction
• Rule 2: 0 - 1 = 1 (1 with a borrow from the next column
to theRule
left)
1 Rule 2 Rule 3 Rule 4 Rule 2
Detail
0 0 1 1 0 (i.e.,
1

- 0 - 1 - 0 - 1 10)
- 1
0 1 1 0 1
Binary Subtraction (cont.)
• Examples of subtraction:
Borrow
1 0 1 1
- 0 0 1 0
ANS= 1 0 0 1

• In the example below, we note that there had to be a borrow


from the Leftmost column.
Borrow 1
1 0 01 0
1

- 1 0 0 1
0 0 0 1
Binary Multiplication
• The rule is that if the multiplier = 1 then we write down the value of
the multiplicand. This will give the product.
Rule 1 Rule 2 Rule 3 Rule 4
0 0 1 1
* 0 * 1 * 0 * 1
0 0 0 1
Binary Multiplication (cont.)
• Examples of multiplication:
A B C
Multiplica 1 1 1
nd
Multiplier * 1 0 1

• The concept is, multiply each multiplicand with each multiplier,


from left to right (green, yellow, then pink). For example:
• 1 *Multiplicand C = 1 * 1 = 1
• 1 *Multiplicand B = 1 * 1 = 1
• 1 *Multiplicand B = 1 * 1 = 1
• Repeat the process, using the multiplier highlighted in yellow. Then
lastly, the multiplier highlighted in pink
Binary Multiplication (cont.)
• Examples of multiplication:
A B C
1 1 1
* 1 0 1
ANS_C= 1 1 1
ANS_B= + 0 0 0
ANS_A= + 1 1 1
Binary Multiplication (cont.)
• Examples of multiplication:
X Y Z A B C
Carry 1 1 1
ANS_C= 1 1 1
ANS_B= + 0 0 0 0
ANS_A= + 1 1 1 0 0
ANS 1 0 0 0 1 1

• Column C=1+0+0=1
• Column B=1+0+0=1
• Column A = 1 + 0 + 1 = 10 (carry 1)
• Column Z = 1 + 0 + 1 = 10 (carry 1)
• Column Y = 1 + 1 = 10
Binary Multiplication (cont.)
• Examples of multiplication:
X Y Z A B C
Carry ? ? ? ? ? ?
1 0 1
* 1 0 1
ANS_C= ? ? ?
ANS_B= + ? ? ?
ANS_A= + ? ? ?
ANS ? ? ? ? ? ?
Binary Division
Quotie
nt
Divisor Dividen
d
Subtrac
t

Remaind
er
Binary Division (cont.)
Logic Circuits
Logic
• This section explains how computers make decisions
• There are 3 main forms of logic circuit
• AND
• OR
• NOT
• The others are combinations of these
Logic and Electric Circuits
• An electric circuit shows how a computer system
handles logic

• When the light is on that is considered a logic 1


• When the light is off that is considered a logic 0
• Remember 0 and 1 are the binary digits
AND Logic , Circuit Example
• The slide shows the way in which electric circuits could be used to control lamps.
Here we see how 2 switches are used to control a single lamp.

A B Light
Open Open Off
Open Closed Off
Closed Open Off
Closed Closed On

• The lamp can only light if both switches are closed.


• We say the switches are in series.
• This is an example of an AND logic circuit.
Truth Table
• The AND logic circuit is represented by the following
picture

A B Output
0 0 0
0 1 0
1 0 0
1 1 1
OR Logic , Circuit Example
• In this diagram the switches are placed next to each other. We say they are
connected in parallel
A B Light
Open Open Off
Open Closed On
Closed Open On
Closed Closed On
Truth Table
• The AND logic circuit is represented by the following
picture

A B Output
0 0 0
0 1 1
1 0 1
1 1 1
NOT Logic , Circuit Example
• The NOT gate which changes the output to the opposite of the input. If the Input is 1 the output
is 0.

A A’
0 1
1 0
Other Gates: NAND or NOT AND
gate
Other Gates: The NOR or the
NOT OR gate
Other Gates: The NOR or the
NOT OR gate

A B A AND B NOT A AND B


0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0
One’s Compliment and Two’s
Compliment
• Written as 1’s Compliment and 2’s Compliment
• 1’s Compliment and 2’s Complements of a binary
numbers represents the negative numbers in digital
systems
• The 2’S complement arithmetic is the predominant
method used in computers when operating with
negative numbers.
One’s Compliment
• 1’s complement of a binary number is simply found by
changing all 1s by 0s and all 0s by 1s.
• For example:
Decimal Binary 1’s Compliment
10 1010 0101
26 11010 00101
55 110111 001000
91 1011011 0100100

• 1’S Complement subtraction method allows subtracting


numbers simply using addition operation only.
One’s Compliment (using 4 bits)
Decimal Binary Positive Negative
(1’s Compliment)
0 000 0000 1111
1 001 0001 1101
2 010 0010 1101
3 011 0011 1100
4 100 0100 1011
5 101 0101 1010
6 110 0110 1001
7 111 0111 1000
8 1000 -
One’s Compliment Subtraction
• Scenario One: Subtracting a small number from a
larger one
1. Determine the 1’S complement of the smaller number.
2. Add the 1’S complement of the smaller number to the larger
number.
3. Add the final carry to the result. This is called an end-around
carry.

• For example (using 1’s Compliment):


• (1110)2 – (1011)2
One’s Compliment Subtraction
(cont.)
Scenario One (continuation):
1. Determine the 1’S complement of the smaller
number.
• (1011)2 is 0100 in 1’s compliment
2. Add the 1’S complement of the smaller number
to the larger
Carry number.
1 1
1 1 1 0
+ 0 1 0 0
ANS= 1 0 0 1 0
One’s Compliment Subtraction
(cont.)
Scenario One (continuation):
3. Add the final carry to the result. This is called an
end-around carry.

Carry 1 1
1 1 1 0
+ 0 1 0 0
0 0 1 0
+ 1
ANS= 0 0 1 1
One’s Compliment Subtraction
• Scenario Two: Subtracting a large number from a
small one
1. Determine the 1’S complement of the larger number.
2. Add the 1’S complement of the larger number to the smaller
number.
3. In this case, there is no carry. The result presents the 1’S
complement of the real answer with the opposite sign.
4. Take the 1’S complement of the result and change its sign to
get the final answer.
• For example (using 1’s Compliment):
• (1011)2 - (1110)2
One’s Compliment Subtraction
(cont.)
Scenario Two (continuation):
1. Determine the 1’S complement of the larger
number.
• (1110)2 is 0001 in 1’s compliment
2. Add the 1’S complement of the larger number to
the smaller
Carry number. 1 1
1 0 1 1
+ 0 0 0 1
1 1 0 0
One’s Compliment Subtraction
(cont.)
Scenario Two (continuation):
3. In this case, there is no carry. The result
presents the 1’S complement of the real answer
with the opposite sign.
Carry 1 1
1 0 1 1
+ 0 0 0 1
ANS= 1 1 0 0
One’s Compliment Subtraction
(cont.)
Scenario One (continuation):
4. Take the 1’S complement of the result and
change its sign to get the final answer.

Carry 1 1
1 0 1 1
+ 0 0 0 1
ANS= 1 1 0 0
F_ANS= 0 0 1 1
Two’s Compliment
• Simply the 2’S complement of a binary number is found
by adding 1 to the 1’s complement of that number.
• For example:
Decimal Binary 1’s 2’s
Compliment Compliment
5 101 010 011
19 10011 01100 01101
Two’s Compliment Subtraction
• As in 1’s complement subtraction, the 2’s complement
subtraction method allows subtracting numbers simply
by using addition operation only.
• Scenario One: Subtracting a small number from a
larger one.
1. Determine the 2’S Complement of the smaller number.
2. Add the 2’s Complement of the smaller number to the larger
number.
3. Discard the final carry from the result to obtain the answer
(always there is a carry in this case).
Two’s Compliment Subtraction
(cont.)
• Scenario Two: Subtracting a larger number from a
small one.
1. Determine the 2’s complement of the larger number.
2. Add the 2’s complement of the larger number to the smaller
number.
3. In this case, there is no carry. The result is in 2’s
complement form and is negative.
4. Take the 2’S complement of the result, and change the sign
to get the answer.

You might also like