You are on page 1of 137

Paskaita bus įrašyta

This lecture will be recorded

. . . .... .... .... . . . . .


Logic gates. Number systems

Saulius Gražulis

Vilnius, 2020

Vilnius University, Faculty of Mathematics and Informatics


Institute of Informatics

This set of slides may be copied and used as specified in the


Attribution-ShareAlike 4.0 International license
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 1 / 28


NOT gate revisited

Input Output Input Output Input Output


L H 0 1 False True
H L 1 0 True False

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 2 / 28


NOT gate revisited

Input Output Input Output Input Output


L H 0 1 False True
H L 1 0 True False

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 2 / 28


NOT gate revisited

Input Output Input Output Input Output


L H 0 1 False True
H L 1 0 True False

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 2 / 28


Boolean functions
Based on the two-element Boolean algebra, or switching
algebra.
B = {0, 1}
B × · · · × B 7→ B

Augustus De Morgan
George Boole
Claude Shannon
Photo by Konrad Jacobs,
reused with permission . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 3 / 28


Number of one-input functions

Input Output
}
0 1
2 positions ⇒ 22 = 4 combinations
1 0

Input Output
0 0 identity f(x ) = x
1 1
Input Output
0 1 NOT f(x ) = x
1 0
Input Output
0 0 constant 0 f(x ) = 0
1 0
Input Output
0 1 constant 1 f(x ) = 1
1 1
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 4 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NAND

X = f(A, B) = A · B = AB
A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 5 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic NOR

X = f(A, B) = A ∨ B
A B X
0 0 1
0 1 0
1 0 0
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 6 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Logic OR (disjunction)

X = f(A, B) = A ∨ B
A B X
0 0 0
0 1 1
1 0 1
1 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 7 / 28


Two-argument Boolean functions

A B X

0 0 1

0 1 1 2
4 positions ⇒ 22 = 16 combinations
1 0 1

1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 8 / 28


Multiple-input logic circuits

A B C D X
0 0 0 0 0
0 1 0 0 0

1 1 1 0 0
1 1 1 1 1

A
B
C
D

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 9 / 28


Computing arbitrary logic function
x1 x2 … xn f(x1 , x2 , . . . , xn ) conjunction
0 0 … 0 1 x1 · x2 · ... · xn
0 1 … 0 1 x1 · x2 · ... · xn
0 1 … 0 0 0
0 1 … 0 0 0
… …
1 1 … 0 1 x1 · x2 · ... · xn
1 1 … 1 0 0

Disjunctive Normal Form (DNF):

f(x1 , x2 , . . . , xn ) = x1 · x2 · ... · xn
∨ x1 · x2 · ... · xn
∨ ...
∨ x1 · x2 · ... · xn

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 10 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


Example: synthesis of the function XOR

A B X conjunction
0 0 0
0 1 1 A·B
1 0 1 A·B
1 1 0

DNF: X = AB ∨ AB

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 11 / 28


NAND gate (revisited)

X = f(A, B) = AB

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 12 / 28


NAND gate (revisited)
X = f(A, B) = AB

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 12 / 28


NAND gate (revisited)
X = f(A, B) = AB

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 12 / 28


NAND gate (revisited)
X = f(A, B) = AB

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 12 / 28


NAND gate (revisited)
X = f(A, B) = AB

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 12 / 28


NAND – a Universal Gate

A B X
0 0 1
0 1 1
1 0 1
1 1 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 13 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates

A B A B A·B A·B A·B A∨B


0 0 1 1 1 1 0 0
0 1 1 0 1 0 1 1
1 0 0 1 1 0 1 1
1 1 0 0 0 0 1 1

A∨B = A·B
A = A
A∨B = A·B = A·B

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 14 / 28


Dual gates, De Morgan laws

}
A·B = A∨B
dual functions
A∨B = A·B

}
A∨B = A·B
De Morgan laws
A·B = A∨B

h is dual of f ⇔ h(x1 , x2 , . . . , xn ) = f(x1 , x2 , . . . , xn )


def
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 15 / 28


Another universal gate: NOR

dual to

dual to

dual to

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 16 / 28


Complete systems of logic functions
Superposition:

h(x1 , . . . , xn ) = f(g1 (x1 , . . . , xn ), . . . , gm (x1 , . . . , xn ))


Example:

NOT(AND(x1 , NOT(x2 )) ≡ x1 x2 = x1 ∨ x2 = x1 ∨ x2
def

Complete systems (examples):


{ }
{AND, OR, NOT} ={ ·, ∨,}X (not minimal!)
{AND, NOT} ={ ·, X}
{OR, NOT} = ∨, X
{AND, XOR, 1} = {·, ⊕, 1}
{OR, XOR, 1} = {∨, ⊕, 1}
{NAND} = {↑} Sheffer stroke
{NOR} = {↓} Peirce’s arrow/Quine’s dagger
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 17 / 28


Closed Boolean function classes
Function classes closed under superposition:
1 T0 : zero-preserving:
f(0, 0, . . . , 0) = 0
2 T1 : one-preserving:
f(1, 1, . . . , 1) = 1
3 S: self-dual:
f(x1 , x2 , . . . , xn ) = f(x1 , x2 , . . . , xn )
4 L: linear:
f(x1 , x2 , . . . , xn ) = a0 ⊕ a1 x1 ⊕ · · · ⊕ an xn
5 M: monotonic:
⃗a ≡ (a1 , a2 , . . . , an )
def
⃗a ≤ ⃗b ⇔ ∀i ∈ {1, . . . , n} : ai ≤ bi
def
f ∈ M ⇔ ⃗a ≤ ⃗b ⇒ f(⃗a) ≤ f(⃗b)
def
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 18 / 28


Post’s theorem
A Boolean function set B = {f1 , f2 , . . . , fn } is complete under
superposition iff:
1 it contains a function that does not preserve 0:
∃ fi ∈ B : fi 6∈ T0
2 it contains a function that does not preserve 1:
∃ fi ∈ B : fi 6∈ T1
3 it contains a function that is not self-dual:
∃ fi ∈ B : fi 6∈ S
4 it contains a function that is not linear:
∃ fi ∈ B : fi 6∈ L
5 it contains a function that is not monotonic:
∃ fi ∈ B : fi 6∈ M
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 19 / 28


Apollo Guidance Computer gates

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 20 / 28


Achievements so far ...

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 21 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2
3

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2
3
4
5
6
7
8
9

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2
3
4
5
6
7
8
9
10

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2
3
4
5
6
7
8
9
10
11

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10
11
12
13
14
15
16
17
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
17 10001
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
17 10001
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 10
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
17 10001
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 10
9 1001 11
10 1010 12
11 1011 13
12 1100 14
13 1101 15
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12
11 1011 13
12 1100 14
13 1101 15
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13
12 1100 14
13 1101 15
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14
13 1101 15
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Binary arithmetic

Representable digits in our hardware: 0 and 1


System: dec bin oct hex
Base: 10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 22 / 28


Expressing numbers

In base b, an m-digit number is represented as a polynomial:

N = am−1 bm−1 + am−2 bm−2 + · · · + a2 b2 + a1 b + a0

Example:

1101012 = 1 · 25 + 1 · 24 + 0 · 23 + 1 · 22 + 0 · 21 + 1 · 20
= 3210 + 1610 + 410 + 110
= 5310
Another example:

1616 = 1 · 161 + 6 · 160 = 1610 + 610 = 2210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 23 / 28


Expressing fractions

In base b, a fraction f = 0.a1 a2 . . . am is represented as a


polynomial:

f = a1 b−1 + a2 b−2 + · · · + am−1 b−m+1 + am b−m

Example:

0.01101012 = 0 · 2−1 + 1 · 2−2 + 1 · 2−3 + 0 · 2−4 +


+1 · 2−5 + 0 · 2−6 + 1 · 2−7

1 1 1 1
= 410 + 810 + 3210 + 12810

= 0.414062510

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 24 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
N = am−1 bm−1 + am−2 bm−2 + · · · + a2 b2 + a1 b + a0
= b(am−1 bm−2 + am−2 bm−3 + · · · + a2 b + a1 ) + a0

Thus, repeated division by a base gives us digits in that base as


reminders:

38 210
1-4
1-7
1-10
1-13
1-16

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
210
210
210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
210
210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 210
210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 210
210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0 0 0

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0 0 0
1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0 0 0
1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting into other number systems
Division by the system’s base gives reminder that is the last digit of
the number:
1001102 /102 = 10011.02 (quotient = 100112 , reminder = 0)
100112 /102 = 1001.12 (quotient = 10012 , reminder = 1)

Thus, repeated division by a base gives us digits in that base as


reminders:
38 210
38 19 210
0 18 9 210
1 8 4 210
1 4 2 210
0 2 1 210
0 0 0
1

1001102 = 25 + 22 + 21 = 3210 + 410 + 210 = 3810 . . . . . . . . . . . . . . . . . . . .


. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 25 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

0.011012 × 102 = 0.11012 ; b0.011012 × 102 c = b0.11012 c = 0


0.11012 × 102 = 1.1012 ; b0.11012 × 102 c = b1.1012 c = 1
1.1012 − b1.1012 c = 0.1012
0.1012 × 102 = 1.012 ; b1.012 c = 1

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

0.1012

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting fractions

Fractions can be multiplied by the new number base to yield


consequently digits after the fraction point:

Convert 0.62510 to binary.


0.62510 × 210 = 1.2510 ; b0.62510 × 210 c = b1.2510 c = 1
1.2510 − b1.2510 c = 0.2510
0.2510 × 210 = 0.510 ; b0.2510 × 210 c = b0.510 c = 0
0.510 − b0.510 c = 0.510
0.510 × 210 = 1.010 ; b1.010 c = 1
1.010 − b1.010 c = 1 − 1 = 0 ⇒ end

0.1012 = 1 · 2−1 + 0 · 2−2 + 1 · 2−3 = 0.510 + 0.12510 = 0.62510

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 26 / 28


Converting to/from base 8 and base 16
Dividing by 810 gives the 3 last binary digits as a reminder:

1101 10112 /810 ≡ 1101 10112 /10002 = 1101 1.0112

Dividing by 1610 gives the 4 last binary digits as a reminder:

1101 10112 /1610 ≡ 1101 10112 /100002 = 1101 .10112

Therefore:
To convert to octal (hexadecimal), group your binary digits by 3 (4)
and convert each group to a corresponding digit:

Octal digits Hex digits


000 0 ←− 0000 0 1000 8
001 1 Example (octal): 0001 1 1001 9
010 2 010110112 = 001 011 0112 = 1338 0010 2 1010 A
011 3 0011 3 1011 B
100 4 −→ 0100 4 1100 C
101 5 Example (hexadecimal): 0101 5 1101 D
110 6 010110112 = 0101 10112 = 5B16 0110 6 1110 E
111 7 0111 7 1111 F
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 27 / 28


Take home messages

Digital circuits can be described using Boolean algebra;


Any Boolean function can be implemented using a complete
set of Boolean functions, as per Post’s theorem; each of
functions NAND and NOR alone form a complete set and
any digital circuit can be build from them;
All Boolean functions can be implemented as electric (e.g.
CMOS FET) switches;
Binary is a natural positional number system for digital
computations; simple algorithms exist to convert numbers
between binary and other number systems, but systems
with bases 8 and 16 are the most convenient to represent
binary numbers.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

Saulius Gražulis Logic gates. Number systems Vilnius, 2020 28 / 28

You might also like