190 likes | 355 Vues
This article explores the representation of numbers in different bases, focusing on base conversions and the concept of complements, particularly the two's complement in binary systems. It details how to represent decimal numbers in base 4, with practical conversion examples, including binary arithmetic operations like addition and subtraction using complements. Detailed definitions of r-complements and binary multiplication are also provided, highlighting their significance in computer arithmetic. Enhance your understanding of numerical representation and computations with these insights.
E N D
Representing numbers in different bases D = an-1 an-2 … a0 . a-1 a-2 … In base r N = an-1 * rn-1 + an-2 * rn-2 + … + a0 + a-1*r-1 + a-2*r-2 + … In base 10:
Representing numbers in different bases Convert: (0.41)10 to ()4
Representing numbers in different bases 0.41 = an-1 * 4n-1 + an-2 * 4n-2 + … + a0 + a-1*4-1 + a-2 * 4-2 + … =0 0.41 = a-1*4-1 + a-2* 4-2 + …
Representing numbers in different bases 0.41 = a-1*4-1 + a-2 * 4-2 + … 4 1.64 = a-1 + a-2 * 4-1 + a-3 * 4-2 <1 a-1 = 1
Complement to Base r Definition: n digits m digits r-complement Number xxxxxxxx . yyyyyy D rn - D n=4 24 2-complement (1101)2 10000-1101 =0011 102 10-complement n=2 100-12 = 88 (12)10
Complement-1 to Base r Definition: n digits m digits (r-1) complement Number xxxxxxxx . yyyyyy D rn-r-m - D n=3 m=2 1-complement (1101.11)2 1111.11-1101.11 =0010.00 9-complement n=1 99-12 = 87 (12)10
Another representation of 2 complement BCD Weight: 2n-1 an-1 an-2 … a0 . a-1 a-2 … 2-complement Weight: -2n-1 BCD Coding Two complement -23 + 22 + 1 1101 = -3 - 0011
Calculating the r complement r complement (r-1) complement rn - D rn-r-m - D +r-m Number (base 2): 1101 +1 1-complement: 0010 0011
0 in complement to 1 1-complement Number 00000 11111 Two representations to 0!
Complement to 1 vs. 2 We usually use 2-complement
Subtraction using 1-complement M – N M + 2n-N-1 = 2n+(M-N-1) M>N-1 M<N-1 Carry <0 >0 2n+(M-N-1) 2n+(M-N-1) No Carry Take the complement and put (-) Carry exists Add it to the result ] -[ 2n – (2n+(M-N-1)) -1 -(N-M) (M-N)
Example I 0011 +1010 3 -5 101 No Carry -010 = -2
Example II 011 +101 3 -2 Carry 000 1 1 001
Changing number of bits Given a number in 2 complement with n bits What is the representation with m>n bits ?
Changing number of bits 0011 1011 11 1011 00 0011
Binary Multiplication 1101 X 0011 13 X 03 1101 1101 100111 39
2-Complement multiplication -3 5 1101 0101 X X 111101 00000 1101 Carry 110001 1
2-Complement multiplication -3 -5 1101 1011 X X ?????
2-Complement multiplication -3 -5 1101 1011 X X 1111101 111101 00000 Remember: Last digit has negative weight 0011 0001111 =15