Digital Logic Chapter 2
Number ConversionsDigital Systems by Tocci
Binary Decimal
Convert a binary number, 1001012, to a decimal number by summing the positional weights that contain “1”.
012345 2*12*02*12*02*02*1
1 0 0 1 0 1
How about Decimal Binary?
32 + 0 + 0 + 4 + 0 + 1 = 3710
Decimal Binary
Use repeated division: Divide the decimal number by 2. The remainder of
this division is the LSB Continue dividing the results, adding the remainders
to the left of the LSB until a quotient of zero is obtained.
The last division is always two into 1 giving a result of 0 with a remainder of 1. This 1 is the MSB.
Additional zeros can be added padding the binary number so the total digits are some multiple of 8.
Repeated Division: Example 1
Until a quotient of “0” is obtained
Repeated Division: Example 2
Repeated Division: Flow Chart
• Similar procedure can be used to convert from decimal to other number systems.
Check your solutions by converting back to decimal.
Hexadecimal Number System
Hexadecimal number system uses base-16 The characters used in hex are:
Digits 0~9 Letters A, B, C, D, E, F The digit positions are weighted as powers of 16, rather
than as powers of 10 as in the decimal system
Counting in Hex
Why Hexadecimal?It is useful to represent long strings of bits. Each character in hex can represent 4 bits reducing the length of a number to a quarter of the original size. It makes binary numbers more “readable”.
Counting in hex restarts at zero and produces a carry after the count reaches F in order to increment to the next value.
Hex Decimal Conversion
Multiplying each hex digit by its positional weight.
Example:
)16(3)16(6)16(1163 01216
131662561
10355
Decimal Hex Conversion Remember the repeated division? Divide the decimal number by 16 The 1st remainder is the LSB and the last is the MSB.
Note, when done on a calculator, a decimal remainder can be multiplied by 16 to get the result.
If the remainder is greater than 9, the letters A~F are used.
Until a quotient of “0” is obtained
Decimal Hex Conversion
Hex Binary Conversion
Hex Binary: Each Hex digit is converted to its four-bit binary equivalent
9F216 = 9 F 2
1001 1111 0010 = 1001111100102
Binary Hex: Convert from binary to hex by grouping bits in four starting with the LSB. Each group is then converted to the hex equivalent Leading zeros can be added to the left of the MSB to fill out the last
group.
Example: 11101001102 = 0011 1010 0110 = 3 A 6
= 3A616
Note the addition of leading zeroes
Conversion among Decimal, Binary, Hex
Decimal
Binary Hexadecimal
How to do all the conversions ?
http://www.learn-programming.za.net/articles_decbinhexoct.html
BCD Code
Binary Coded Decimal (BCD) is another way to present decimal numbers in binary form.
BCD is widely used and combines features of both decimal and binary systems.
Each BCD digit is converted to a binary equivalent.
To convert the number 87410 to BCD:
8 7 4 0100 0111 0100 = 010001110100BCD
Each decimal digit is represented using 4 bits. Each 4-bit group can never be greater than 9. Reverse the process to convert BCD to decimal
Decimal BCD
BCD
BCD is NOT a number system. BCD is a decimal number with each digit
encoded to its binary equivalent. The primary advantage of BCD: easy to convert
to and from binary. A BCD number is NOT the same as a straight
binary number.
BCD Review Questions
Is “1001 1011 0101” a valid BCD?
BYTE, Nibble, WORD
Byte: Most microcomputers handle and store binary
data in groups of 8 bits. So, special name is given to a string of 8 bits,
called a byte. Two common questions:
How many bytes in a 32-bit string (a string of 32 bits)?
What is the largest decimal number that can be represented in binary using two bytes?
BYTE, Nibble, WORD
Byte = 8 bits Nibble = 4 bits Word:
Word size in a simple system may be one byte (8 bits)
Word size in a PC is 8 bytes (64 bits) Word size is specific to particular machines.
Alphanumeric Codes – ASCII Code
Represents characters and functions found on a computer keyboard.
ASCII – American Standard Code for Information Interchange. Seven bit code: 27 = 128 possible code groups Table 2-4 lists the standard ASCII codes Applications:
To transfer information between computers, between computers and printers, and for internal storage.
Parity Method for Error Detection
Binary data and codes are frequently moved between locations. For example: Digitized voice over a microwave link. Storage and retrieval of data from hard disks. Communication between computer systems over
telephone lines using a modem. Electrical noise can cause errors during
transmission. Many digital systems employ methods for error
detection (and sometimes correction).
Parity Method for Error Detection
The parity method of error detection requires the addition of an extra bit to a code group.
This extra bit is called the parity bit. The bit can be either a 0 or 1, depending on the
number of 1s in the code group. There are two methods: even and odd.
Even Parity Method: The total number of “1”s in a group, including the parity bit, must add up to an even number. The binary group 1 0 1 1 would require the
addition of a parity bit 1 1 0 1 1 The parity bit may be added at either end of a group.
Odd Parity Method: The total number of “1”s in a group, including the parity bit, must add up to an odd number.
Parity Method for Error Detection
Parity Method for Error Detection
The transmitter and receiver must “agree” on the type of parity-checking being used.
Two bit errors would not indicate a parity error.
Both odd and even parity methods are used, but even seems to be used more often.
Schematic for Even Parity Generator
Top Related