Você está na página 1de 37

MCT 2333

Digital Number System


Dr. Hazlina Md Yusof

Digital Number System


The

hexadecimal number system is


introduced in this chapter.
Since different number systems may
be used in a system, it is important for
a technician to understand how to
convert between them.
Binary codes that are used to
represent different information are
also described in this chapter.

Binary to Decimal
Conversion
Convert

binary to decimal by
summing the positions that
contain a 1.

1 0 0 1 0 12
25 2 4 23 2 2 21 20 32 4 1 3710

Decimal to Binary
Conversion

Two methods to convert decimal


to binary:

Reverse process described in 2-1


Use repeated division

Decimal to Binary
Conversion

Reverse process described in 21

Note that all positions must be


accounted for

3710 2 0 0 2 0 2
5

12

Decimal to Binary
Conversion
Repeated

division steps:

Divide the decimal number by 2


Write the remainder after each
division until a quotient of zero is
obtained.
The first remainder is the LSB and
the last is the MSB
Note, when done on a calculator, a
fractional answer indicates a remainder
of 1.

Decimal to Binary Conversion


Repeated

division
This flowchart
describes the
process and can
be used to convert
from decimal to
any other number
system.

Hexadecimal Number
System

Most digital systems deal with groups


of bits in even powers of 2 such as 8,
16, 32, and 64 bits.
Hexadecimal uses groups of 4 bits.
Base 16
16 possible symbols
0-9 and A-F
Allows

for convenient handling of long


binary strings.

Hexadecimal Number
System
Convert

from hex to decimal by


multiplying each hex digit by its
positional weight.
Example:

16316 1 (16 2 ) 6 (161 ) 3 (160 )


1 256 6 16 3 1
35510

Hexadecimal Number
System
Convert

from decimal to hex by using the


repeated division method used for decimal
to binary and decimal to octal conversion.
Divide the decimal number by 16
The first 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 through F are used.

Hexadecimal Number
System
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hexadecimal 0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Binary
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Example

of hex to binary
conversion:

9F216 = 9
F
2
1001 1111 0010 =
1001111100102

Hexadecimal Number
System
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.

2-3 Hexadecimal Number


System
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hexadecimal 0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Binary
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

Example

of binary to hex conversion.

(Note the addition of leading zeroes)

11101001102 = 0011 1010 0110


=
3
A
6
= 3A616
Counting

in hex requires a reset and carry


after reaching F.

Hexadecimal Number
System
Hexadecimal

is useful for
representing long strings of bits.
Understanding the conversion
process and memorizing the 4 bit
patterns for each hexadecimal
digit will prove valuable later.

Binary Addition
Binary

numbers are added like


decimal numbers.
In decimal, when numbers sum more
than 9 a carry results.
In binary when numbers sum more
than 1 a carry takes place.
Addition is the basic arithmetic
operation used by digital devices to
perform subtraction, multiplication,
and division.

Representing Signed
Numbers
Since

it is only possible to show


magnitude with a binary number, the
sign (+ or ) is shown by adding an
extra sign bit.
A sign bit of 0 indicates a positive
number.
A sign bit of 1 indicates a negative
number.
The 2s complement system is the
most commonly used way to
represent signed numbers.

Representing Signed
Numbers
In

order to change a binary number to 2s


complement it must first be changed to 1s
complement.

To convert to 1s complement, simply change each bit to its


complement (opposite).
To convert 1s complement to 2s complement add 1 to the
1s complement.

positive number is true binary with 0 in the sign


bit.
A negative number is in 2s complement form with 1
in the sign bit.

Representing Signed
Numbers

A number is negated when converted


to the opposite sign.
A binary number can be negated by
taking the 2s complement of it.

Addition in the 2s Complement


System
Perform

normal binary addition of


magnitudes.
The sign bits are added with the magnitude
bits.
If addition results in a carry of the sign bit, the
carry bit is ignored.
If the result is positive it is in pure binary
form.
If the result is negative it is in 2s complement
form.

Subtraction in the 2s Complement


System
The

number subtracted (subtrahend)


is negated.
The result is added to the minuend.
The answer represents the difference.
If the answer exceeds the number of
magnitude bits an overflow results.

Multiplication of Binary
Numbers
This

is similar to multiplication of
decimal numbers.
Each bit in the multiplier is multiplied
by the multiplicand.
The results are shifted as we move
from LSB to MSB in the multiplier.
All of the results are added to obtain
the final product.

Binary Division
This

is similar to decimal long division.


It is simpler because only 1 or 0 are
possible.
The subtraction part of the operation is
done using 2s complement subtraction.
If the signs of the dividend and divisor
are the same the answer will be positive.
If the signs of the dividend and divisor
are different the answer will be negative.

Hexadecimal Arithmetic
Hex

addition:

Add the hex digits in decimal.


If the sum is 15 or less express it directly in
hex digits.
If the sum is greater than 15, subtract 16
and carry 1 to the next position.
Hex

subtraction use the same


method as for binary numbers.
When the MSD in a hex number is 8 or
greater, the number is negative.
When the MSD is 7 or less, the number
is positive.

BCD
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 digit is converted to a binary
equivalent.

BCD
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.

BCD
BCD

is not a number system.


BCD is a decimal number with
each digit encoded to its binary
equivalent.
A BCD number is not the same as
a straight binary number.
The primary advantage of BCD is
the relative ease of converting to
and from decimal.

Gray Code
The

gray code is used in


applications where numbers
change rapidly.
In the gray code, only one bit
changes from each value to the
next.

Gray Code
Binary
000
001
010
011
100
101
110
111

Gray Code
000
001
011
010
110
111
101
100

Putting It All Together

The Byte, Nibble, and


Word
1

byte = 8 bits
1 nibble = 4 bits
1 word = size depends on data
pathway size.
Word size in a simple system may be
one byte (8 bits)
Word size in a PC is eight bytes (64
bits)

Alphanumeric Codes
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
Examples of use are: 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 magnetic
and optical 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).
Ronald Tocci/Neal Widmer/Gregory
Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

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.
Ronald Tocci/Neal Widmer/Gregory
Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

Parity Method for Error


Detection
Even

parity method the total


number of bits 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
1011
Note that the parity bit may be added at
either end of a group.

Ronald Tocci/Neal Widmer/Gregory


Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

Parity Method for Error


Detection
Odd

parity method the total


number of bits in a group
including the parity bit must add
up to an odd number.
The binary group 1 1 1 1 would
require the addition of a parity bit 1
1111

Ronald Tocci/Neal Widmer/Gregory


Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

Parity Method for Error


Detection
The

transmitter and receiver


must agree on the type of
parity checking 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.
Ronald Tocci/Neal Widmer/Gregory
Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

2-10 Applications
A

CD-ROM stores 650 megabytes of


digital data. How many bits of data is
this?
Determine the odd parity bit required
for each of the following 7 bit ASCII
codes:
_ 1001010
_ 0101101
_ 0110101
Determine

the even parity bit required


for each 7 bit ASCII code listed above.

Ronald Tocci/Neal Widmer/Gregory


Moss
Digital Systems: Principles and
Applications, 10e

Copyright 2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.

Você também pode gostar