You are on page 1of 39

Week 1: Lecture 2

The Number System and Logic Gates

Dr Mohsan Waseem

November 15, 2022


Questions

The Analog Computer: uses the continuous variation aspect of


physical phenomena
electrical, mechanical, hydraulic quantities
to model the problem being solved.
Became obsolete in 1960’s but remained in use in specific
applications.
Most relatable example are mechanical watches: periodic rotation of
gears drive needles!
Are they programmable? ...

2 / 39
Number Systems
The Decimal System

Consider a number say 7,392.


7000 + 300 + 90 + 2
7 × 103 + 3 × 102 + 9 × 101 + 2 × 100
This is a decimal number that we are familiar with.
Conventionally we only write the numeric coefficients.
The powers of 10 are deduced from the position of coefficients.
In general, a number with a decimal point is represented by a series
of coefficients:
...a4 a3 a2 a1 a0 .a−1 a−2 a−3 ...
The coefficients aj are any of the 10 digits (0 to 9) and the
subscript j gives the place (power of 10).
The number in the above expression can be written as

...a4 104 +a3 103 +a2 102 +a1 101 +a0 100 +.a−1 10−1 +a−2 10−2 +a−3 10−3 +...

3 / 39
Number Systems
The Decimal System

The decimal number system is said to be of base 10.


It uses 10 digits and the coefficients are multiplied by powers of 10.
Similarly, we have another number system that have only two
possible values 0 and 1.
This system is called the binary system, a system with the base 2.

4 / 39
Number Systems
The Binary System

In a binary system, each coefficient aj is multiplied by a power of 2


and the results are added to obtain the decimal equivalent of the
number.
The radix point (decimal point in case of base 10 numbers)
distinguishes positive powers of 10 from negative powers of 10.
For example: Consider the binary number 11010.11, the decimal
equivalent of this will be

1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 + 1 × 2−1 + 1 × 2−2 =?

5 / 39
Number Systems
The Binary System

In a binary system, each coefficient aj is multiplied by a power of 2


and the results are added to obtain the decimal equivalent of the
number.
The radix point (decimal point in case of base 10 numbers)
distinguishes positive powers of 10 from negative powers of 10.
For example: Consider the binary number 11010.11, the decimal
equivalent of this will be

1 × 24 + 1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 + 1 × 2−1 + 1 × 2−2 = 26.75

6 / 39
Number Systems
Gernalised Number System

In general, a number expressed in a base-r system has coefficients


multiplied by powers of r:

an × rn + an−1 × rn−1 ... + a0 × r0 + a−1 × r−1 ... + a−m × r−m

The coefficients aj range in value from 0 to r-1.


To distinguish between numbers of different bases, we enclose the
coefficients in parentheses and write a subscript equal to the base
used.
Consider a number (4021.2)5 , what is decimal equivalent of this?
(Note that coefficients can on assume values 0-4)

7 / 39
Number Systems
Gernalised Number System

In general, a number expressed in a base-r system has coefficients


multiplied by powers of r:

an × rn + an−1 × rn−1 ... + a0 × r0 + a−1 × r−1 ... + a−m × r−m

The coefficients aj range in value from 0 to r-1.


To distinguish between numbers of different bases, we enclose the
coefficients in parentheses and write a subscript equal to the base
used.
Consider a number (4021.2)5 , what is decimal equivalent of this?
(Note that coefficients can on assume values 0-4)

4 × 53 + 0 × 52 + 2 × 51 + 1 × 50 + 2 × 5−1 =?

8 / 39
Number Systems
Gernalised Number System

In general, a number expressed in a base-r system has coefficients


multiplied by powers of r:

an × rn + an−1 × rn−1 ... + a0 × r0 + a−1 × r−1 ... + a−m × r−m

The coefficients aj range in value from 0 to r-1.


To distinguish between numbers of different bases, we enclose the
coefficients in parentheses and write a subscript equal to the base
used.
Consider a number (4021.2)5 , what is decimal equivalent of this?
(Note that coefficients can on assume values 0-4)

4 × 53 + 0 × 52 + 2 × 51 + 1 × 50 + 2 × 5−1 = (511.4)10

9 / 39
Number Systems
Octal Number System

The octal number system is a base-8 system.


Coefficients can be 0, 1, 2, 3, 4, 5, 6, 7.
An example: (127.4)8 to decimal equivalent

1 × 82 + 2 × 81 + 7 × 80 + 4 × 8−1 = (87.5)10

It is customary to borrow the needed r digits for the coefficients from


the decimal system when the base of the number is less than 10.
What if r > 10?.... the hexadecimal number system (base 16)

10 / 39
Number Systems
Hexadecimal Number System

In such cases, the letters of alphabet are used to supplement the 10


decimal digits.
The the first 10 digits are borrowed from the decimal system.
The letters A, B, C, D, E, and F are used for the digits 10, 11, 12,
13, 14, and 15, respectively.
An example: (B65F )16 to decimal equivalent

11 × 163 + 6 × 162 + 5 × 161 + 15 × 160 = (46, 687)10

The hexadecimal system is used commonly by designers to represent


long strings of bits in the addresses, instructions, and data in digital
systems.
For example, 1011011001010000 is represented by B65F.

11 / 39
Number Systems
Binary Digits: Bits

In computer work, 210 is referred to as kilo K, 220 : mega M, 230 :


giga G and 240 : tera T.
Computer capacity is usually given in bytes.
A byte is equal to eight bits and can accommodate one keyboard
character.
A computer hard disk with four gigabytes of storage has a capacity
of 4G = 4 × 230 = 232 bytes (approximately 4 billion bytes).
A terabyte is 1024 gigabytes, approximately 1 trillion bytes.

12 / 39
Number Systems
Binary Arithmetic Rules

Addition

101101 + 100111 =

13 / 39
Number Systems
Binary Arithmetic Rules

Subtraction

101101 − 100111 =

14 / 39
Number Systems
Binary Arithmetic Rules

Multiplication

1011 × 101 =
15 / 39
Number Systems
Base Conversion

Representations of a number in a different bases are said to be


equivalent if they have the same decimal representation.
(0011)8 = (1001)2 ?
The conversion of a number in base r to decimal is done by
expanding the number in a power series and adding all the terms.
Now we discuss the conversion from a decimal number to a number
in base r.
If the number includes a radix point, it is necessary to separate the
number into an integer part and a fraction part, since each part
must be converted differently.

16 / 39
Number Systems
Base Conversion

The conversion of a decimal integer to a number in base r is done by


dividing the number and all successive quotients by r and
accumulating the remainders.
Example, convert decimal 41 to binary.

17 / 39
Number Systems
Base Conversion

The conversion of a decimal integer to a number in base r is done by


dividing the number and all successive quotients by r and
accumulating the remainders.
Example, convert decimal 41 to binary.
Answer: (101001)2

18 / 39
Number Systems
Base Conversion

The conversion of a decimal integer to a number in base r is done by


dividing the number and all successive quotients by r and
accumulating the remainders.
Example, convert decimal 153 to octal.

19 / 39
Number Systems
Base Conversion

The conversion of a decimal integer to a number in base r is done by


dividing the number and all successive quotients by r and
accumulating the remainders.
Example, convert decimal 153 to octal.
Answer: (231)8

20 / 39
Number Systems
Base Conversion

The conversion of a decimal fraction to binary is accomplished by a


method similar to that used for integers.
Multiplication is used instead of division, and integers instead of
remainders are accumulated.
Example, convert decimal 0.6875 to binary.

21 / 39
Number Systems
Base Conversion

The conversion of a decimal fraction to binary is accomplished by a


method similar to that used for integers.
Multiplication is used instead of division, and integers instead of
remainders are accumulated.
Example, convert decimal 0.6875 to binary.
Answer: (0.1011)2

22 / 39
Number Systems
Base Conversion

The conversion of a decimal fraction to binary is accomplished by a


method similar to that used for integers.
Multiplication is used instead of division, and integers instead of
remainders are accumulated.
Example, convert decimal 0.513 to octal.

23 / 39
Number Systems
Base Conversion

The conversion of a decimal fraction to binary is accomplished by a


method similar to that used for integers.
Multiplication is used instead of division, and integers instead of
remainders are accumulated.
Example, convert decimal 0.513 to octal.
Answer: (0.406517)8

24 / 39
Number Systems
Base Conversion

The conversion from and to binary, octal, and hexadecimal plays an


important role in digital computers, because shorter patterns of hex
characters are easier to recognize than long patterns of 1’s and 0’s.
Since 23 = 8 and 24 = 16, each octal digit corresponds to three
binary digits and each hexadecimal digit corresponds to four binary
digits.
The conversion from binary to octal is easily accomplished by
partitioning the binary number into groups of three digits each,
starting from the binary point and proceeding to the left and to the
right.
The corresponding octal digit is then assigned to each group.

25 / 39
Number Systems
Base Conversion

The conversion from binary to octal is easily accomplished by


partitioning the binary number into groups of three digits each,
starting from the binary point and proceeding to the left and to the
right.
The corresponding octal digit is then assigned to each group.

26 / 39
Number Systems
Base Conversion

Conversion from binary to hexadecimal is similar, except that the


binary number is divided into groups of four digits:

27 / 39
Number Systems
Base Conversion

28 / 39
Number Systems
Binary Coded Decimal BCD

The binary number system is the most natural system for a computer
because it is readily represented in today’s electronic technology.
People however are more used to the decimal system.
How to resolve this issue?....
Convert Decimal to Binary
Perform calculations.
Convert Binary to Decimal
simple but there is a problem...
We need to store decimal numbers in the computer so that they can
be converted to binary and computers do not read decimal numbers.
they only accept binary codes.
We can represent the decimal digits by means of a code that
contains 1’s and 0’s.
The additional advantage is that it is possible to perform the
arithmetic operations directly on decimal numbers when they are
stored in the computer in coded form.
29 / 39
Number Systems
Binary Coded Decimal BCD

Consider a decimal 185

30 / 39
Number Systems
American Standard Code for Information Interchange (ASCII)

31 / 39
Binary Logic

Binary logic consists of binary variables and a set of logical


operations.
The variables are designated by letters of the alphabet, such as A,
B, C, x, y, z, etc.,
Each variable can only have two and only two distinct possible
values: 1 and 0.
There are three basic logical operations: AND, OR, and NOT.

32 / 39
Binary Logic
Logical Operations

33 / 39
Binary Logic
Logical Operations

34 / 39
Binary Logic
Logical Operations

35 / 39
Binary Logic
Logical Operations

36 / 39
Binary Logic
Logic Gates

Logic gates are electronic circuits that operate on one or more input
signals to produce an output signal.
Electrical signals such as voltages or currents exist as analog signals
having values over a given continuous range, say, 0 to 3 V.
In a digital system these voltages are interpreted to be either of two
recognizable values, 0 or 1.
Voltage operated logic circuits respond to two separate voltage
levels that represent a binary variable equal to logic 1 or logic 0.

37 / 39
Binary Logic
Logical Operations

38 / 39
Binary Logic
Logical Operations

39 / 39

You might also like