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

DLD Chapter2

This document covers the fundamentals of number systems, including decimal, binary, and hexadecimal representations. It explains conversion methods between these systems, binary arithmetic operations, and the representation of signed numbers using 1's and 2's complements. Additionally, it discusses Binary Coded Decimal (BCD) and its applications in digital systems.

Uploaded by

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

DLD Chapter2

This document covers the fundamentals of number systems, including decimal, binary, and hexadecimal representations. It explains conversion methods between these systems, binary arithmetic operations, and the representation of signed numbers using 1's and 2's complements. Additionally, it discusses Binary Coded Decimal (BCD) and its applications in digital systems.

Uploaded by

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

Kibur College

Department of Computer science

Digital Logic Design


CHAPTER – II: Number System

1
Introduction to Numbering System
Decimal Numbers

 In the decimal number system each of the ten digits 0 through 9 represents a
certain quantity.
 The base(radix) of decimal numbers is 10.
 The position of each digit in a weight number system is assigned a weight
based on the base of the system.
 Powers of ten that increase from right to the column weights of decimal
numbers are left beginning with 10^0 , 10^1 , 10^2,10^3 ...
Decimal Numbers
 For fractional decimal numbers, the column weights are negative powers of ten
that decrease from left to right.
 Decimal numbers can be expressed as the sum of the products of each digit times
the column values for that digit.
Example
Binary Numbers

 The binary number system is another way to represent quantities.


 It have two digits: 0 and 1.
 so it is base 2 system.
Binary-to-decimal Conversion

 The decimal value of any binary number can be found by


adding the weights of all bits that are 1 and discarding the
weights of all bits that are 0
Class Exercise

1. What is the largest decimal number that can be represented


in
binary with eight bits?
2. Determine the weight of the 1 in the binary number 10000.

3. Convert the binary number 10111101.011 to decimal.


Decimal –To -Binary Conversion

1. 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.
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
Example
Exercise

 Convert decimal number 39 to binary.

16
Binary Arithmetic
 Binary arithmetic is essential in all digital computers and in many other
types of digital systems.
 To understand digital systems, you must know the basics of binary
addition, subtraction, multiplication, and division.
 This section provides an introduction that will be expanded in later
sections.

 After completing this section, you should be able to

 Add binary numbers


 Subtract binary numbers
 Multiply binary numbers
 Divide binary numbers
Binary Addition
 The four basic rules for adding binary digits (bits) are as
follows:
 0 + 0 = 0 Sum of 0 with a carry of 0
 0 + 1 = 1 Sum of 1 with a carry of 0
 1 + 0 = 1 Sum of 1 with a carry of 0
 1 + 1 = 10 Sum of 0 with a carry of 1

 In Binary 1 +1=10, Not The Decimal Digit 2.


Example
Binary Subtraction

 The four basic rules for subtracting bits are as follows


 0-0=0
 1-1=0
 1-0=1
 10 - 1 = 1 0 - 1 with a borrow of 1

20
Example

21
Example 2

22
Solution

23
Binary Multiplication

 The four basic rules for multiplying bits are as follows:


 0*0=0
 0*1=0
 1*0=0
 1*1=1

24
Example

25
Binary Division Example

 Division in binary follows the same


procedure as division in decimal.

26
Checkup
 1. Perform the following binary additions:
(a) 1101 + 1010
(b) 10111 + 01101
 2. Perform the following binary subtractions:
(a) 1101 - 0100
(b) 1001 - 0111
 Perform the indicated binary operations:
(a) 110 * 111
(b) 1100 , 011
27
1’S And 2’S Complements Of
Binary Numbers
 The 1’s complement and the 2’s complement of a binary number are important because
they permit the representation of negative numbers.
 The method of 2’s complement arithmetic is commonly used in computers to handle
negative numbers.
 After completing this section, you should be able to
 Convert a binary number to its 1’s complement
 Convert a binary number to its 2’s complement using either of two method

28
Finding the 1’s Complement

 The 1’s complement of a binary number is found


by changing all 1s to 0s and all 0s to 1s, as
illustrated below:

29
Finding the 2’s Complement

 The 2’s complement of a binary number is found by adding 1 to the LSB of the 1’s
complement.

30
Example

31
Signed Numbers
 Digital systems, such as the computer, 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.
 There are three forms in which signed integer (whole) numbers can be
represented in binary:
 Sign-magnitude,
 1’s complement, and
 2’s complement.
 Of these, the 2’s complement is the most important and the32sign-
magnitude is the least used.
The Sign Bit
 The left-most bit in a signed binary number is the sign bit, which
tells you whether the number is positive or negative.
A 0 sign bit indicates A positive number, and A 1 sign
bit indicates A negative number.

33
Sign-magnitude Form
 When a signed binary number is represented in sign-magnitude, the left-
most bit is the sign bit and the remaining bits are the magnitude bits.
 The magnitude bits are in true (uncomplemented) binary for both positive
and negative numbers.
 For example, the decimal number +25 is expressed as an 8-bit signed
binary number using the sign-magnitude form as

34
Cont’d

 The decimal number -25 is expressed as


10011001
 Notice that the only difference between +25 and -25 is the sign bit because the magnitude
bits are in true binary for both positive and negative numbers.
 In the sign-magnitude form, a negative number has the same magnitude bits as
the corresponding positive number but the sign bit is a 1 rather than a zero

35
1’s Complement Form

 Positive numbers in 1’s complement form are represented the same way as the positive
sign-magnitude numbers.
 Negative numbers, however, are the 1’s complements of the corresponding positive numbers.
 For example, using eight bits, the decimal number -25 is
expressed as the 1’s complement of +25 (00011001) as 11100110
 The 1’s complement form, a negative number is the 1’s complement of the
corresponding positive number.

36
2’s Complement Form
 Positive numbers in 2’s complement form are represented the same way as in the sign
magnitude and 1’s complement forms.
 Negative numbers are the 2’s complements of the corresponding positive numbers.
 Again, using eight bits, let’s take decimal number -25 and express it as the 2’s complement of
+25 (00011001).
 Inverting each bit and adding 1, you get
-25 = 11100111
 in the 2’s complement form, a negative number is the 2’s complement of the corresponding
positive number

37
Arithmetic Operations With Signed
Numbers
 Addition
 The two numbers in an addition are the addend and the augend. The result is the sum.
There are four cases that can occur when two signed binary numbers are added.
1. Both numbers positive
2. Positive number with magnitude larger than negative number
3. Negative number with magnitude larger than positive number
4. Both numbers negative
 Let’s take one case at a time using 8-bit signed numbers as examples. The equivalent
decimal numbers are shown for reference.

38
39
40
Hexadecimal Numbers

 The hexadecimal number system has a base of sixteen; that is, it is composed of 16
numeric and alphabetic characters.
 Most digital systems process binary data in groups that are multiples of four bits,
making the hexadecimal number very convenient because each hexadecimal digit
represents a 4-bit binary number.

41
Hexadecimal
Numbers

42
Binary-to-Hexadecimal
Conversion
 Converting a binary number to hexadecimal is a
straightforward procedure.
 Simply break the binary number into 4-bit groups,
starting at the right-most bit and replace each 4-bit
group with the equivalent hexadecimal symbol.

43
Example

44
Hexadecimal-to-binary
Conversion
 To convert from a hexadecimal number to a binary
number, reverse the process and replace each
hexadecimal symbol with the appropriate four bits.

45
Example

46
Hexadecimal-to-decimal
Conversion
 One way to find the decimal equivalent of a hexadecimal number is
to first convert the
hexadecimal number to binary and then convert from binary to
decimal.

47
Hexadecimal-to-decimal
Conversion
 Another way to convert a hexadecimal number to its decimal
equivalent is to multiply the decimal value of each hexadecimal
digit by its weight and then take the sum of these products.
 The weights of a hexadecimal number are increasing powers of
16 (from right to left).
 For a 4-digit hexadecimal number, the weights are

48
Example

49
Decimal-to-Hexadecimal
Conversion
 Repeated division of a decimal number by 16 will produce the
equivalent hexadecimal number, formed by the remainders of
the divisions.
 The first remainder produced is the least significant digit
(LSD).
 Each successive division by 16 yields a remainder that
becomes a digit in the equivalent hexadecimal number.

50
Example

51
Hexadecimal addition
 Addition can be done directly with hexadecimal numbers by remembering
that the hexadecimal digits 0 through 9 are equivalent to decimal digits 0
through 9 and that hexadecimal digits A through F are equivalent to decimal
numbers 10 through 15.
 When adding two hexadecimal numbers, use the following rules. (Decimal
numbers are indicated by a subscript 10.)
 1. In any given column of an addition problem, think of the two
hexadecimal digits in
terms of their decimal values. For instance, 516 = 510 and C16 =
1210.
 2. If the sum of these two digits is 1510 or less, bring down the
corresponding hexadecimal digit.
 3. If the sum of these two digits is greater than 1510, bring down the
amount of the sum 52

that exceeds 1610 and carry a 1 to the next column.


Example

53
Exercise
 Add 4C16 and 3A16

54
Binary Coded Decimal (BCD)

 Binary coded decimal (BCD) is a way to express each of


the decimal digits with a binary code.
 There are only ten code groups in the BCD system, so it is
very easy to convert between decimal and BCD.
 Because we like to read and write in decimal, the BCD
code provides an excellent interface to binary systems.
 Examples of such interfaces are keypad inputs and digital
readouts.

55
The 8421 BCD Code

 The 8421 code is a common type of BCD (binary coded decimal)


code.
 Binary coded decimal means that each decimal digit, 0 through
9, is represented by a binary code of four bits.
 The designation 8421 indicates the binary weights of the four
bits (23, 22, 21, 20).

56
Invalid Codes
 Invalid Codes you should realize that, with four bits, sixteen
numbers (0000
through 1111) can be represented but that, in the 8421 code,
only ten of these are used.
 The six code combinations that are not used—1010, 1011,
1100, 1101, 1110, and 1111—are invalid in the 8421 BCD
code.

57
Example

58
Applications of BCD

 Digital clocks, digital thermometers, digital meters, and other


devices with seven-segment displays typically use BCD code to
simplify the displaying of decimal numbers.
 BCD is not as efficient as straight binary for calculations, but it
is particularly useful if only limited processing is required, such
as in a digital thermometer.

59
BCD addition
 BCD is a numerical code and can be used in arithmetic operations.

 Addition is the most important operation because the other three operations (subtraction,
multiplication, and division) can be accomplished by the use of addition.

 Here is how to add two BCD numbers:


Step 1: Add the two BCD numbers, using the rules for binary addition.
Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated,
it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the six invalid states and
return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit
group. 60
Example

61
Cont’d

62
Exercise
1. Convert hexadecimal number 4100 to binary:
2. Convert binary number 1111110000 to hexadecimal:
3. Convert hexadecimal number F3 to decimal:
4. Convert decimal number 6500 to hexadecimal:
5. Perform the additions hexadecimal number: A0 + 6B
6. Add the following BCD numbers:
A. 01010001 + 01011000
B. 10011000 + 10010111
63
End Of The Chapter

64

You might also like