1

I have an application which is using 24 bit fixed point calculation.I am porting it to a hardware which does support floating point, so for speed optimization I need to convert all fixed point based calculation to floating point based calculation.

For this code snippet, It is calculating mantissa

for(i=0;i<8207;i++)
{
  // Do n^8/7 calculation and store 
  // it in mantissa and exponent, scaled to 
  // fixed point precision.

}

So since this calculation, does convert an integer to mantissa and exponent scaled to fixed point precision(23 bit). When I tried converting it to float, by dividing the mantissa part by precision bits and subtracting the exponent part by precision bit, it really does' t work. Please help suggesting a better way of doing it.

2 Answers 2

2

Just calculate a conversion factor and multiply by it. What value represents 1.0 in your fixed point system? Multiply by 1.0/that and you'll have your conversion.

Fixed point generally refers to a fixed number of bits for the integer part, and a fixed number of bits for the fractional part. By your description, I'm going to guess that you have 1 bit of integer and 23 bits of fraction; therefore your representation of 1.0 is 0x80000. The conversion factor is 1.0/0x80000.

double conversionFactor = 1.0 / 0x80000;
floating = fixed * conversionFactor;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. Can you please elaborate it with a handy example as it will help a lot.
1

If your fixed point numbers have 23 bits of fraction,

f = n * (1.0 / 0x800000)

1 Comment

Should it be applicable for both mantissa and exponent. or only on mantissa. What should I do with exponent part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.