0% found this document useful (0 votes)
25 views13 pages

Lecture #2

Uploaded by

Nahom Biniyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views13 pages

Lecture #2

Uploaded by

Nahom Biniyam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

3.

Number systems
Decimal Number System
 A number consists of digits that have 10 possible values, from 0 to 9.
 Decimal numbers are also called base (radix) -10 numbers.
 Each digit represents a multiple of a power of 10.

Consider the following general representation of a number with a decimal


point
a5a4a3a2a1a0. a-1a-2a-3
 The coefficients aj are any of the 10 digits (0, 1, 2, . . ., 9), and the subscript value j gives
the place value.
 Thus, the decimal number representation can be expressed as
105a5 + 104a4 + 103a3 + 102a2 + 101a1 + 100a0 + 10-1a-1 + 10-2a-2 + 10-3a-
3
• For example, the number 8547 represents
8 × 103 + 5 × 102 + 4 × 101 + 7 × 100
 Decimal numbers are familiar but not practical in digital circuits.
1
Binary (base-2) Number System
 Digits can be 0 or 1.
 Each binary digit (0 or 1) is called a bit.
 Used in digital systems.
 Nibble: A group of four bits.
 Byte: A group of eight bits.
 Using positional number representation, the binary number
B = a5a4a3a2a1a0. a-1a-2a-3
represents an integer that has the value
V(B) = 25a5 + 24a4 + 23a3 + 22a2 + 21a1 + 20a0 + 2-1a-1 + 2-2a-2 + 2-3a-3
. . . . . . Eq. (1)
 For example, the binary number 1101 represents the value
V = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
To specify that 1101 is a base-2 number, we will write (1101) 2.
Evaluating the preceding expression for V gives.
V = 8 + 4 + 1 = 13
Hence,
2 (1101)2 = (13)10
Octal and Hexadecimal Representations
 In octal representation the digit values range from 0 to 7.
 In hexadecimal representation each digit can have one of 16 values (0 to 9 and A,
B, C, D, E & F)
 The A, B, C, D, E, and F corresponds to the decimal values 10, 11, 12, 13, 14,
and 15.
DECIMAL BINARY HEXADECIMAL OCTAL
0 0000 0 0
1 0001 1 1 • The octal and
2 0010 2 2
3 0011 3 3
hexadecimal
4 0100 4 4 systems is that
5 0101 5 5 they serve as a
6 0110 6 6 useful shorthand
7 0111 7 7 notation for
8 1000 8 10 binary numbers.
9 1001 9 11
10 1010 A 12
11 1011 B 13
12 1100 C 14
13 1101 D 15
14 1110 E 16
3 15 1111 F 17
Number‐Base Conversions
 The conversion of a number in base r to decimal is done by expanding
the number in a power series and adding all the terms.
 for the reverse operation of converting a decimal number to a number in
base r:
• If the number includes a radix point, separate the number into
an integer part and a fraction part.
• The conversion of a decimal integer to a number in base r is
done by dividing the number and all successive quotients by r
and accumulating the remainders.
• The conversion of a decimal fraction to binary is
accomplished by a method similar to that used for integers.
However, multiplication is used instead of division, and
integers instead of remainders are accumulated.

4
 Example 1: Convert the decimal number 857 in to binary.
Repeated division by 2
Remainder
857 ÷ 2 = 428 1 LSB
428 ÷ 2 = 214 0
214 ÷ 2 = 107 0
107 ÷ 2 = 53 1
53 ÷ 2 = 26 1
26 ÷ 2 = 13 0
13 ÷2 = 6 1
6 ÷2 = 3 0
3 ÷2 = 1 1
1÷2=0 1 MSB

Result is (1101011001)2

5
 Example 2: Convert (0.6875)10 to binary
Repeated multiplication by 2.
Integer Fraction Coefficient
0.6875 x 2 = 1 + 0.3750 a-1 = 1
0.3750 x 2 = 0 + 0.7500 a-2 = 0
0.7500 x 2 = 1 + 0.5000 a-3 = 1
0.5000 x 2 = 1 + 0.0000 a-4 = 1

Therefore, (0.6875)10 = (0. a-1 a-2 a-3 a-4)2 = (0.1011)2.


 The conversion of decimal numbers with both integer and fraction
parts is done by converting the integer and the fraction separately and
then combining the two answers.
Thus,
(857.6875)10 = (1101011001.1011)2

6
Exercise
A) Convert decimal 55 to octal.
B) Convert decimal 0.45 to octal.

7
 One octal digit represents three bits
 The conversion from binary to octal is easily accomplished by partitioning
the binary number into groups of three digits each, starting from the binary
point and proceeding to the left and to the right. The corresponding octal
digit is then assigned to each group.

For example, 10110001101011.111100000110


is converted as
(10 110 001 101 011.111 100 000 110)2
=(26153.7406)8
2 6 1 5 3 7 4 0 6

which means that (0110001101011.111100000110)2 =


(26153.7406)8

o Conversion from octal to binary is just as straightforward; each


octal digit is simply replaced by three bits that denote the same
value.
8
 Similarly, a hexadecimal digit is represented using four bits.
 Conversion from binary to hexadecimal is similar, except that the binary
number is divided into groups of four digits:

(10 1100 0110 1011.1111 0010)2 = (2C6B.F2)16


2 C 6 B F 2

 Conversion from hexadecimal to binary involves straightforward


substitution of each hexadecimal digit by four bits that denote the same
value.

 There are many different number systems. In general, a number expressed


in a base‐r system has coefficients multiplied by powers of r:
an r n + an-1 r n-1 + . . . + a2r 2 + a1r + a0 + a-1 r-1+ a-2r-2 + . . .+
a-m r-m
9
The coefficients aj range in value from 0 to r – 1.
 Binary Codes
 Any discrete element of information that is distinct among a group of
quantities can be represented with a binary code (i.e., a pattern of 0’s and
1’s).
 The minimum number of bits required to code 2 n distinct quantities is n.
 Binary-Coded Decimal Code (BCD)
 In digital systems it is possible to represent decimal numbers simply by encoding each
digit in binary form. This is called the binary-coded-decimal (BCD) representation.
 10 digits to encode
o necessary to use four bits per digit.
 Each digit is encoded by the binary pattern that represents its unsigned value.

 The binary combinations1010 through 1111 are not used and have no meaning in BCD.
10
 A number with k decimal digits will require 4k bits in BCD.
 Example: Decimal 396 is represented in BCD as:
0011 1001 0110
each group of 4 bits representing one decimal digit.
 BCD Addition
• Example

• The addition of two n‐digit unsigned BCD numbers is carried


out by adding each digit in BCD and transferring the carry to the
next higher significant digit.

11
 Gray Code
 Only one bit in the code group changes in going from one number to the next.
 Used in applications which may produce an error or ambiguity during the
transition from one number to the next.
DECIMAL BINARY GRAY CODE
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010 Reading:
13 1101 1011  Conversion from binary to gray and
14 1110 1001 vise versa
15 1111 1000
12  Application of gray code
 ASCII Character Code
 The standard binary code for the alphanumeric characters is the
American Standard Code for Information Interchange (ASCII),
which uses seven bits to code 128 characters.
 Error‐Detecting Code
 To detect errors in data communication and processing, an eighth bit
is sometimes added to the ASCII character to indicate its parity.
 A parity bit is an extra bit included with a message to make the total
number of 1’s either even or odd.
With even parity With odd parity
ASCII A = 1000001 01000001 11000001
ASCII T = 1010100 11010100 01010100
 In each case, we insert an extra bit in the leftmost position of the code
to produce an even number of 1’s in the character for even parity or an
odd number of 1’s in the character for odd parity.
 By checking the parity of each character, error can be detected.

13

You might also like