Lecture #2
Lecture #2
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.
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
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.
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
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