CSE231 – Digital Logic Design
Lecture – 2 Lesson Outcomes
After completing this lecture, students will be able to
Express the number systems and covert one form
to another
Number Systems, Perform the arithmetic operations in various
number systems
Operations Express decimal numbers to binary coded decimal
(BCD) form
CSE231 Lecture 2 Page 1/39
Key Terms
Alphanumeric Consisting of numerals, letters, and other characters.
ASCII American Standard Code for Information Interchange; the most widely used
alphanumeric code.
BCD Binary coded decimal; a digital code in which each of the decimal digits, 0 through 9, is
represented by a group of four bits.
Byte A group of eight bits.
Cyclic redundancy check (CRC) A type of error detection code.
Floating-point number A number representation based on scientific notation in which the
number consists of an exponent and a mantissa.
Hexadecimal Describes a number system with a base of 16.
LSB Least significant bit; the right-most bit in a binary whole number or code.
MSB Most significant bit; the left-most bit in a binary whole number or code.
Octal Describes a number system with a base of eight.
Parity In relation to binary codes, the condition of evenness or oddness of the number of 1s
in a code group.
CSE231 Lecture 2 Page 2/39
Decimal numbers
The decimal number system has a base of 10.
The value of a digit is determined by its position in the number.
The value of a decimal number is the sum of the digits after each digit has been
multiplied by its weight
CSE231 Lecture 2 Page 3/39
Binary numbers
CSE231 Lecture 2 Page 4/39
Binary numbers – application (counting)
CSE231 Lecture 2 Page 5/39
Binary to decimal number
CSE231 Lecture 2 Page 6/39
Decimal to binary – sum of weights method
CSE231 Lecture 2 Page 7/39
Decimal to binary - division by 2 method
CSE231 Lecture 2 Page 8/39
Decimal to binary conversion
CSE231 Lecture 2 Page 9/39
Binary operation
CSE231 Lecture 2 Page 10/39
Binary operation
CSE231 Lecture 2 Page 11/39
Complements in 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.
CSE231 Lecture 2 Page 12/39
The signed numbers
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.
Using 8-bit signed binary number, the Using 8-bit signed binary number, the
decimal number +25 is expressed as decimal number -25 is expressed as
CSE231 Lecture 2 Page 13/39
1’s and 2’s complements in signed numbers
In the 1’s complement form, a negative number is the 1’s complement of the
corresponding positive number.
In the 2’s complement form, a negative number is the 2’s complement of the
corresponding positive number.
8-bit number for +39 is: 00100111
In the sign-magnitude form, -39 is: 10100111
In the 1’s complement form, 239 is: 11011000
In the 2’s complement form, 239 is:
CSE231 Lecture 2 Page 14/39
Range of signed integer numbers
The formula for finding the number of different combinations of n bits is
For 2’s complement signed numbers, the range of values for n-bit numbers is
For example, with 8 bits the range is: -128 to +127
With 16 bits, the range is: -32768 to + 32767
CSE231 Lecture 2 Page 15/39
Floating-point numbers
To represent very large integer numbers, many bits are required. There is also a problem
when numbers with both integer and fractional parts, such as 23.5618, need to be
represented. The floating-point number system, based on scientific notation, is capable
of representing very large and very small numbers without an increase in the number of
bits and also for representing numbers that have both integer and fractional
components.
A floating-point number (also known as a real number) consists of two parts plus a sign.
The mantissa is the part of a floating-point number that represents the magnitude of the
number and is between 0 and 1. The exponent is the part of a floating-point number that
represents the number of places that the decimal point (or binary point) is to be moved.
Let’s consider a decimal number which, in integer form, is 241,506,800. The mantissa is
.2415068 and the exponent is 9. The floating-point number is written as 0.2415068 × 109.
CSE231 Lecture 2 Page 16/39
Single-precision floating-point binary numbers
In the standard format for a single-precision binary number, the sign bit (S) is the
left-most bit, the exponent (E) includes the next eight bits, and the mantissa or
fractional part (F) includes the remaining 23 bits,
The general approach to determining the value of a floating-point number is
expressed by
CSE231 Lecture 2 Page 17/39
Decimal to floating-point binary number
CSE231 Lecture 2 Page 18/39
Example 2-1
PROBLEM: Determine the binary value of the following floating-point binary number.
PROBLEM:
CSE231 Lecture 2 Page 19/39
Arithmetic operations in signed numbers
CSE231 Lecture 2 Page 20/39
Arithmetic operations in signed numbers
CSE231 Lecture 2 Page 21/39
Binary multiplication
The basic steps in the partial products method of binary multiplication are as follows:
Step 1: Determine if the signs of the multiplicand and multiplier are the same or different.
This determines what the sign of the product will be.
Step 2: Change any negative number to true (uncomplemented) form. Because most
computers store negative numbers in 2’s complement, a 2’s complement operation is
required to get the negative number into true form.
Step 3: Starting with the least significant multiplier bit, generate the partial products.
When the multiplier bit is 1, the partial product is the same as the multiplicand.
When the multiplier bit is 0, the partial product is zero. Shift each successive partial
product one bit to the left.
Step 4: Add each successive partial product to the sum of the previous partial products to
get the final product.
Step 5: If the sign bit that was determined in step 1 is negative, take the 2’s complement of
the product. If positive, leave the product in true form. Attach the sign bit to the product.
CSE231 Lecture 2 Page 22/39
Example 2-2
PROBLEM: Multiply the signed binary numbers: 01010011 (multiplicand) and 11000101 (multiplier).
SOLUTION
Step 1: The sign bit of the multiplicand is 0 and the sign bit of
the multiplier is 1. The sign bit of the product will be 1
(negative).
Step 2: Take the 2’s complement of the multiplier to put it in
true form. 11000101 00111011
Step 3 and 4: The multiplication proceeds as follows. Notice
that only the magnitude bits are used in these steps.
Step 5: Since the sign of the product is a 1 as determined in
step 1, take the 2’s complement of the product.
1001100100001 0110011011111
CSE231 Lecture 2 Page 23/39
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 (as listed in Table 2–3).
Counting hexadecimal numbers: ….., E, F, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C,
1D, 1E, 1F, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 2A, 2B, 2C, 2D, 2E, 2F, 30, 31, .....
CSE231 Lecture 2 Page 24/39
Binary to hexadecimal conversion
CSE231 Lecture 2 Page 25/39
Hexadecimal to binary number
CSE231 Lecture 2 Page 26/39
Hexadecimal to decimal conversion
CSE231 Lecture 2 Page 27/39
Hexadecimal to decimal conversion (weighted method)
CSE231 Lecture 2 Page 28/39
Decimal to hexadecimal
CSE231 Lecture 2 Page 29/39
Hexadecimal addition
CSE231 Lecture 2 Page 30/39
Octal number
Octal to
decimal
number
CSE231 Lecture 2 Page 31/39
Decimal to octal conversion
CSE231 Lecture 2 Page 32/39
Octal to binary conversion
CSE231 Lecture 2 Page 33/39
Binary to octal conversion
CSE231 Lecture 2 Page 34/39
Binary coded decimal (BDC)
The 8421 BCD Code: The 8421 code is a 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).
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.
Applications: Digital clocks, digital thermometers, digital meters, and other devices with seven-
segment displays typically use BCD code to simplify the displaying of decimal numbers.
CSE231 Lecture 2 Page 35/39
Decimal to BCD and vice versa
CSE231 Lecture 2 Page 36/39
BCD addition
CSE231 Lecture 2 Page 37/39
References
1. Digital Fundamentals by Thomas Floyd, Pearson International Edition,
11th Edition, Chapter 2, Page 65-109.
CSE231 Lecture 2 Page 38/39
Next class
Logic Gates
CSE231 Lecture 2 Page 39/39