# Is there a standard way to convert from a fixed point notation to a floating point notation?

Fixed point numbers can be in many different forms depending on the number of bits before and after the decimal expressed as Qm.n.

Floating point numbers can be in many forms depending on the number of bits specified for the exponent and mantissa. The sign bit will always be there.

What methods exist to convert between these?

• Are you talking about notation (designed to be human-readable) or encoding (designed for machine processing and communication) ? Commented Oct 19, 2021 at 16:43
• Like in the answer Marcus provided, I also think more in it as a method and not as a "formula". It may be also the case that you have two methods, since the IEEE floating point format includes a "sub-normal range" which, as the name implies, is not normalized with an implicit "1." bit. Commented Oct 19, 2021 at 16:45
• Is there some research paper or book that covers this topic? Commented Oct 19, 2021 at 16:57
• "Handbook of Floating-Point Arithmetic" by Jean-Michel Muller is the classic reference I know. Commented Oct 19, 2021 at 17:00
• This question is not clear. When you say "convert" do you mean using pencil and paper or code? If code, in what language? Commented Oct 19, 2021 at 19:42

way to convert from a fixed point notation to a floating point notation?

Assuming:

1. only normalized floating point representation
2. two's complement for negative fixed point numbers
3. -0.0 float will not be generated from fixed point

Exponent bias depend on the specific format, so it is ignored below (it is up to the decision on how to represent negative exponents)

For both directions:

if zero:
return zero


There is no signed integer, there is fixed point number.

If you are not concerned with negative fixed point numbers, just skip step 1.

Fixed point to floating point:

1. negative number (set float sign bit and transform the two's complement to the positive representation: overflow happens for the minimum value but may fit in the float representation)

2. find the most significant '1'

3. if fixed >= 1.0 and < 2.0, this is the mantissa, exponent = 0 (FINISH)

4. If fixed >= 2.0, shift right to reach the the range in 3. The shift amount is the positive exponent

5. If fixed < 1.0, shift left to reach the the range in 3. The shift amount is the negative exponent

Truncate or fill the mantissa with zeros to fit the floating point representation. Rounding may affect the exponent.

Well, you need to define a "true" value conversion for both formats and then apply that.

In other words, for your fixed-point format, you need to define what m and n are in your case; that would give you the dynamic range of that format. Then, you'd extract the position of the highest set bit to figure out what your floating point number's exponent needs to be – and then you'd shift your number by the bit positions necessary to make the rest fit into your mantissa.

• I have made the last line of question clearer. Commented Oct 19, 2021 at 19:38
1. Express your signed fixed-point number as a signed integer. That is, treat the binary value as though it were simply a signed integer and determine that value.

2. Use floating-point division to divide the signed integer by $$\2^n\$$, where $$\n\$$ is the number of fraction bits.

3. There is no step 3. You are done.

• There is no signed integer, there is fixed point number. Also, if I need to use floating point divider to do this task, it kinds of defeats the purpose really. Commented Oct 19, 2021 at 19:54
• If the purpose is something other than converting a fixed point number to a float, then you need to tell us. What operations are allowed and which defeat the purpose? We can't help unless we know the (apparently arbitrary) rules. Commented Oct 19, 2021 at 20:24
• You don't need a divider to divide by 2^N.
– user16324
Commented Oct 19, 2021 at 20:24
• @quantum231 I've been writing fixed-point, real-time, signal processing software for decades. But good luck to you. Commented Oct 19, 2021 at 22:04