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

Lecture 02

Uploaded by

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

Lecture 02

Uploaded by

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

Number Systems

Asst. Prof. Mohanad Alayedi


Department of Software Engineering
Haliç University
[email protected]

CEN203, Fall 2024

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 1


Overview

➢ The design of computers


• It all starts with numbers
• Building circuits
• Building computing machines

➢ Digital systems
➢ Understanding decimal numbers
➢ Binary and octal numbers
• The basis of computers!

➢ Conversion between different number systems

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 2


Digital Computer Systems

➢ Digital systems consider discrete amounts of data.


➢ Examples
• 26 letters in the alphabet
• 10 decimal digits

➢ Larger quantities can be built from discrete values:


• Words made of letters
• Numbers made of decimal digits (e.g. 239875.32)

➢ Computers operate on binary values (0 and 1)


➢ Easy to represent binary values electrically
• Voltages and currents.
• Can be implemented using circuits
• Create the building blocks of modern computers

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 3


Understanding Decimal Numbers
➢ Decimal numbers are made of decimal digits: (0,1,2,3,4,5,6,7,8,9)
➢ But how many items does a decimal number represent?
• 8653 = 8x103 + 6x102 + 5x101 + 3x100
➢ What about fractions?
• 97654.35 = 9x104 + 7x103 + 6x102 + 5x101 + 4x100 + 3x10-1 + 5x10-2
• In formal notation -> (97654.35)10
➢ Why do we use 10 digits, anyway?

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 4


Understanding Octal Numbers
➢ Octal numbers are made of octal digits:
(0,1,2,3,4,5,6,7)
➢ How many items does an octal number represent?
(4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10
➢ What about fractions?
• (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2
➢ Octal numbers don’t use digits 8 or 9
➢ Who would use octal number, anyway?

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 5


Understanding Binary Numbers
➢ Binary numbers are made of binary digits (bits):
• 0 and 1

➢ How many items does an binary number represent?


• (1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10

➢ What about fractions?


• (110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2

➢ Groups of eight bits are called a byte


• (11001001) 2

➢ Groups of four bits are called a nibble.


• (1101) 2

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 6


Why Use Binary Numbers?

➢ Easy to represent 0 and 1 using electrical values.


➢ Possible to tolerate noise.
➢ Easy to transmit data
➢ Easy to build binary circuits.

AND Gate

1
0
0

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 7


Conversion Between Number Bases

Octal(base 8)

Decimal(base 10) Binary(base 2)

Hexadecimal
(base16)
➢ Learn to convert between bases.
➢ Already demonstrated how to convert
from binary to decimal.
➢ Hexadecimal described in next lecture.

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 8


Convert an Integer from Decimal to Another Base

For each digit position:


1. Divide decimal number by the base (e.g. 2)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.

Example for (13)10:


Integer Remainder Coefficient
Quotient
13/2 = 6 + ½ a0 = 1
6/2 = 3 + 0 a1 = 0
3/2 = 1 + ½ a2 = 1
1/2 = 0 + ½ a3 = 1

Answer (13)10 = (a3 a2 a1 a0)2 = (1101)2


CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 9
Convert an Fraction from Decimal to Another Base

For each digit position:


1. Multiply decimal number by the base (e.g. 2)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes zero.

Example for (0.625)10:


Integer

0.625 x 2 = 1 + 0.25 a-1 = 1


0.250 x 2 = 0 + 0.50 a-2 = 0
0.500 x 2 = 1 + 0 a-3 = 1

Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 10


The Growth of Binary Numbers
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512

2 22=4 10 210=1024

3 23=8 11 211=2048

4 24=16 12 212=4096

5 25=32 20 220=1M
Mega
6 26=64 30 230=1G
Giga
7 27=128 40 240=1T
Tera
CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 11
Binary Addition

Binary addition is very simple.


This is best shown in an example of adding two binary numbers…

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 12


Binary Subtraction

➢ We can also perform subtraction (with borrows in place of carries).


➢ Let’s subtract (10111)2 from (1001101)2…

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 13


Binary Multiplication

➢ Binary multiplication is much the same as decimal multiplication, except that


the multiplication operations are much simpler…

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 14


Convert an Integer from Decimal to Octal

For each digit position:


1. Divide decimal number by the base (8)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.

Example for (175)10:


Integer Remainder Coefficient
Quotient
175/8 = 21 + 7/8 a0 = 7
21/8 = 2 + 5/8 a1 = 5
2/8 = 0 + 2/8 a2 = 2

Answer (175)10 = (a2 a1 a0)8 = (257)8

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 15


Convert an Fraction from Decimal to Octal

For each digit position:


1. Multiply decimal number by the base (e.g. 8)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes
zero.
Example for (0.3125)10:
Integer Fraction Coefficient

0.3125 x 8 = 2 + 5 a-1 = 2
0.5000 x 8 = 4 + 0 a-2 = 4

Answer (0.3125)10 = (0.a-1 a-2)2 = (0.24)8

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 16


Summary

➢ Binary numbers are made of binary digits (bits)


➢ Binary and octal number systems
➢ Conversion between number systems
➢ Addition, subtraction, and multiplication in binary

CEN203, Fall 2024 2024, Dr. Mohanad Alayedi (Haliç University) 17

You might also like