Have following questions about Fixed point conversion format.
Suppose I want to change Fixed Point format as
X1(m1,n1) (→) X2(m2,n2),m1+n1=m2+n2[Word length same], n2>n1[ Higher Fractionlength]
Suppose X1=00001100 and suppose I do X1<<(2^3)
Q1) If I interpret X1 as pure Signed integer, then X1= 12 and above operation means Multiply by 2^(n2-n1)=8 so that X2= 01100000 = 96. (Decimal point is irrelevant here?). Is the interpretation correct?
or Assuming Fixed point notation, above means
X1(m1,n1) (→) X2(m1-K,n1+k),m1+n1=m2+n2[Word length same], n2>n1[ Higher Fractionlength] and k=n2-n1 For given example, this means X1(3,5)=000.011 00(0.375)(→) X2(0,8)= .01100000=0.375
So, the value remained same.
Q2) Can we always interpret this as decimal point being fixed and bits moved left?Is this a logical shift or arithmatic shift?
Q3) Ideally, we would like to preserve resolution and range covered. Under what condition would this be guaranteed for the above shift? for example, consider following conversions:
Consider X1(3,5)=101.011 00(5.375)(→) X2(0,8) is 101.01100<<3 = .01100000 =0.375.So, we have error.
Q4) Is this rounding or truncation and why?
Consider X1(m1n1) = 000...0 . abc......z , [m1 = all zeroes], X1 << k = X1(m1-k,m1+k) where k<=m1
would not change the value, as bits to the left and right of decimal point remain same
Q5) So, if fixed point fractional notation is assumed( Positive fraction, with magnitude <1), Left shifts smaller than integer word length would preserve the fractional value?
Suppose I have fixed point number X1(m1,n1) with Word length m1+n1. Suppose I want to express
it in X2(m2,n2) format so that Word length is reduced ,Fraction length is increased, Integer Word length reduced but the value remains the same.For example:
X1(3,5) = 000.01100(0.375) -> X2(1,6)
Steps for above could be:
Left shift by n2-n1 bits so that 000 011 00 <<1 = 000 110 00
Keep Least Significant m2+n2 bits so that X2 = 0.011000(0.375) or Keep Most Significant m2+n2 bits so that X2 = 0.001100(0.1875)
Q6) If I was writing a routine that would automatically do conversion, )(say this was Sum result that needed to be converted to output (m2.n2) format automatically), how are what decides whether I keep LS or MS bits or doing a left or right shift?
Suppose I have fixed point number X1(m1,n1) with Word length m1+n1. Suppose I want to express it in X2(m2,n2) format so that Word length is increased ,Fraction length is increased but the value remains the same.For example:
X1(3,5) = 100.01100(-3.625) -> X2(3,13)
and X1(3.5) = 100.01100(-3.635) -> X2(1,11)
Q7) How can I go about that? What would be steps if result required increase in Word length and Integer Word Length?
Suppose I need to convert Fixed Point number as per
X1(m+1,n) (→) X2(m,n)[ Word length reduced, Fraction length same, integer Word length reduced]
One of the references I found says do following :
(x1)&(0xff..e) and keep MS m2+n2 bits
With X1(1,4) = 0.1011(0.875) this becomes 0.101 = 0.75
Other says: Do left shift by 1 and Keep Ms m2+n2 bits With X1(1,4) = 1.011(0.875) this becomes 1.011(0.625)
Obviously, i don't perverse the value.
Q8) Is there a correct way to do it and the logic behind it?
I know these are lot of questions but it will help me clear lot of confusing stuff.