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.
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 × 2 2 + 0 × 2 1 + 1 × 2 0
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
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
The coefficients aj range in value from 0 to r – 1.
Arithmetic operation
Arithmetic operations with numbers in base r follow the same rules as for
decimal numbers.
Examples of addition, subtraction, and multiplication of two binary numbers are
as follows:
3
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, as
it is done in eq. 1.
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
6
Exercise
A) Convert decimal 55 to octal.
B) Convert decimal 0.45 to octal.
7
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.
8
The octal and hexadecimal systems is that they serve as a useful shorthand
notation for binary numbers.
One octal digit represents three bits
o 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.
10
Complements of Numbers
• Complements are used in digital computers to simplify the subtraction
operation and for logical manipulation.
• There are two types of complements for each base‐r system:
• The radix/r’s complement and the diminished radix/(r - 1)’s
complement.
Diminished Radix Complement
• Given a number N in base r having n digits, the (r - 1)’s complement of N
is defined as (r n - 1) - N.
11
For binary numbers, r = 2 and r - 1 = 1, so the 1’s complement of N is (2 n - 1) - N.
o Similar to the decimal case, the 1’s complement of a binary number is
obtained by subtracting each digit from 1.
o However, when subtracting binary digits from 1, we can have either
1 - 0 = 1 or 1 - 1 = 0, the bit toggles.
Example:
The 1’s complement of 1011001 is 0100110.
Radix Complement
The r’s complement of an n‐digit number N in base r is defined as r n - N for
N ≠ 0 and as 0 for N = 0.
we note that the r’s complement is obtained by adding 1 to the (r -
1)’s complement, since rn -N = [(r n- 1) - N] + 1.
Example: The 2’s complement of binary 100100 is 011011 + 1 = 011100.
The 2’s complement can be formed by leaving all least significant 0’s and the
first 1 unchanged and replacing 1’s with 0’s and 0’s with 1’s in all other higher
significant digits.
Example: The 2’s complement of 1101110 is 0010010
The complement of the complement restores the number to its original
value .
12