Presentation is loading. Please wait.

Presentation is loading. Please wait.

Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider.

Similar presentations


Presentation on theme: "Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider."— Presentation transcript:

1 Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider the integral part of the number, X I, in the  d system : R is the Desired digit (LSD) – Can Repeatedly Divide to Obtain Converted Value Consider the integral part of the number, X I, in the  d system : If X I is divided by  d, we obtain x 0 as a remainder and quotient

2 Radix Conversion Example X I = 346 10  s =10  d =3 Fixed-point Decimal to Ternary Integer Conversion Check by evaluating the radix polynomial X I = 110211 3

3 Radix Conversion (fractional) Consider the fractional part of the value in  d Fixed point system Thus, P I is the Desired Digit We can Repeatedly Multiply by the  d Value

4 Radix Conversion Example X I = 0.291 10  s =10  d =5 Fixed-point Decimal to Pentary Fractional Conversion 0.291 10 is Finite Fraction for  s =10, but infinite fraction for  d =5

5 Fixed Point Negative Numbers Two Common Forms: 1.Signed-magnitude Form 2.Complement Forms Signed Magnitude First Digit is Sign Digit, Remaining n-1 are the Magnitude Convention (binary) –0 is a Positive Sign bit –1 is a Negative Sign bit Convention (non-binary) –0 is a Positive Sign digit –  -1 is a Negative Sign digit Only 2  n-1 Digit Sequences are Utilized

6 Signed Magnitude Example Largest Representable Value is:

7 Signed Magnitude Example (cont)

8 Signed Magnitude Ternary Example Notice that fractional part is infinite in  =10 but finite in  =3

9 Signed Magnitude Ternary Bounds Positive Numbers: Negative Numbers: Range:

10 Signed Magnitude Comments Two Representations for zero, +0 and –0 Addition of +K and –K is not zero EXAMPLE 10001010.00 2 +00001010.00 2 10010100.00 2 -10 10 +10 10 Yields a Sum of –20 10 !!!!!

11 Complement Representations Two Types of Complement Representations 1. radix complement (binary – 2’s complement) 2. diminished radix complement (binary – 1’s complement) Positive Values Represented Same Way as Signed Magnitude for Both Types Negative Value, -Y, Represented as R-Y Where R is a Constant Obeys the Identity: Advantage is No Decisions Needed Based on Operand Sign Before Operations are Applied

12 Complement Representation Example If |Y|>X, Then the Answer is R-(Y-X) If X>|Y|, Then the Answer Should be X-Y –But X+(R-Y)=R+(X-Y), Thus R Must be Discarded! Solution is to Choose the Value of R Carefully X is Positive, Y is Negative, Compute X+Y Using Complement Representation

13 Requirements for Complementation Value, R Select R to Simplify (or Eliminate) Correction for the X>|Y| Case Calculation of Complement of Y, (R-Y) Should be Simple and Fast Definition of Complement for Single Digit, x i Definition of Complement for a Word, X

14 Complementation Value, R Add Word and Complement Together: Answer to Addition Now Add 1 ulp Therefore, we see that:

15 Radix Complement Form The Radix Complement Form is Defined When: Using  k is Convenient Since Storing Result in Register of Length n Causes MSD of 1 to be Discarded due to Finite Register Length Therefore, it is Easy to Compute the Complement of X by: 1.Take the Complement of X 2.Add 1ulp to Complement

16 Radix Complement Form (cont) No Correction is Needed When We have Positive X and Negative Y Such That: Since R=  k And  k is discarded Due to Finite Register Length

17 Radix Complement Example Since n = m + k  m=0 Therefore 1 ulp = 2 0 =1 Given X, the radix complement (2’s complement) is: Range of Positive Numbers is [0000,0111] 2’s Complement of Largest, 0111: In Radix Complement, There is a Single Representation of Zero (0000) and Each Positive Number has Corresponding Negative Number With MSB=1

18 Radix Complement Example In Radix Complement, There is a Single Representation of Zero (0000) and Each Positive Number has Corresponding Negative Number With MSB=1 Accounts for 1(zero)+7(pos.)+7(neg.), But Extra Bit Pattern Left One Additional Negative Number, 1000 2 =-8 10, -8 10  X  +7 10

19 Diminished Radix Complement In Diminished Radix Complement, the Complementation Process is Easier Since the Addition of 1 ulp is Avoided Range of Positive Numbers is: [0000 2,0111 2 ]=[0 10,7 10 ] 1’s Complement of Largest is 1000 2 = -7 10 1’s Complement of Zero is 1111 2 Two Representations of Zero! In All Cases MSB is Sign Bit

20 Comparison of Two’s Complement, One’s Complement and Signed-Magnitude SequenceTwo’s Complement One’s Complement Signed- Magnitude 011333 010222 001111 000000 111-0-3 110-2-2 101-3-2 100-4-3-0


Download ppt "Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider."

Similar presentations


Ads by Google