1 / 19

Representing numbers in different bases

Representing numbers in different bases. D = a n-1 a n-2 … a 0 . a -1 a -2 …. In base r. N = a n-1 * r n-1 + a n-2 * r n-2 + … + a 0 + a -1 *r -1 + a -2 *r -2 + …. In base 10:. Representing numbers in different bases. Convert:. (0.41) 10 to () 4.

kalila
Télécharger la présentation

Representing numbers in different bases

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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:

  2. Representing numbers in different bases Convert: (0.41)10 to ()4

  3. 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 + …

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

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

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

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

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

  9. 0 in complement to 1 1-complement Number 00000 11111 Two representations to 0!

  10. Complement to 1 vs. 2 We usually use 2-complement

  11. 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)

  12. Example I 0011 +1010 3 -5 101 No Carry -010 = -2

  13. Example II 011 +101 3 -2 Carry 000 1 1 001

  14. Changing number of bits Given a number in 2 complement with n bits What is the representation with m>n bits ?

  15. Changing number of bits 0011 1011 11 1011 00 0011

  16. Binary Multiplication 1101 X 0011 13 X 03 1101 1101 100111 39

  17. 2-Complement multiplication -3 5 1101 0101 X X 111101 00000 1101 Carry 110001 1

  18. 2-Complement multiplication -3 -5 1101 1011 X X ?????

  19. 2-Complement multiplication -3 -5 1101 1011 X X 1111101 111101 00000 Remember: Last digit has negative weight 0011 0001111 =15

More Related