DLD 2022 2
DLD 2022 2
DLD 2022 2
Number Systems
Fall 2022
Decimal Numbers
• The decimal number system has ten digits (0-9)
• The decimal number system has a base of 10
• The position of each digit in a decimal number indicates the
magnitude and assigned with weight.
………105 104 103 102 101 100
.
……………102 101 100 10-1 10-2 10-3 ………..
2
Decimal Numbers
• The value of a decimal number is the sum of the digits
multiplied by its weight
3
Binary Numbers
• The binary number system has two digits (bits) 0 and 1
• The binary number system has a base of 2
• The weight or value of a bit increases from right to left in a
binary number
4
Binary Numbers
• The right-most bit is the LSB (least significant bit) in a binary
number and has a weight of 20 = 1
• The weights increase from right to left by a power of two for
each bit
• The left-most bit is the MSB (most significant bit)
1101101 = 64+ 32 + 0 + 8 + 4 + 0 + 1
= 109
6
Decimal to Binary
• Sum-of-Weights Method
• To get the binary number for a given decimal number, find the
binary weights that add up to the decimal number
23 2 2 2 1 2 0
1 0 0 1 Binary number for decimal 9
7
Decimal to Binary
• Repeated Division-by-2 Method
• To get the binary number for a given decimal number, divide the
decimal number by 2 until the quotient is 0. Remainders form
the binary number.
• Convert the following decimal numbers to binary: (a) 19 (b) 45
8
Binary Arithmetics
• Binary Addition
9
Binary Arithmetics
• Binary Subtraction
10
Binary Arithmetics
• Binary Multiplication
11
Binary Arithmetics
• Binary Division
• Perform the following binary divisions:
12
Complements of Binary Numbers
• The 1’s complement and the 2’s complement of a binary
number represents the negative numbers
• 2’s complement is commonly used in computers to handle
negative numbers
13
Complements of Binary Numbers
• 1’s Complement
• The 1’s complement of a binary number is found by
changing all 1s to 0s and all 0s to 1s:
14
Complements of Binary Numbers
• 2’s Complement
• The 2’s complement of a binary number is found by adding
1 to the LSB of the 1’s complement
2’s complement = (1’s complement) + 1
15
Signed Numbers
• Digital systems must be able to handle both positive and
negative numbers. A signed binary number consists of both
sign and magnitude information. The sign indicates
whether a number is positive or negative, and the
magnitude is the value of the number
16
Signed Numbers
17