How are large and small Floating point values represented with Fixed point

Viewed 409

I know that on machines without Floating Point Units, such numbers should either be represented in fixed point or FPU is emulated using libc.

In the former case, how are very large and very small FPU values repined in fixed point? my understanding is that fixed point has a limited number of decimal resolution explained here: Is fixed point math faster than floating point?

So if I try to compile a very small/large FP value in C, for a machine without an FPU, how would that number get repressed in fixed point?

2 Answers

In principle it does not matter whether you have a common floating point number (for example IEEE-754 float or double) or a fixed point number. Both have their limits towards very large (absolute) values and towards very small values.

  • A very small number (less than the smallest fixed point value not equal to zero, or the half of it, depending on rounding) will be represented as zero. Approaching the lower limit will raise the inaccuracy, because the number of available digits gets smaller.

  • A very large number (more than the absolut value of the largest fixed point, and a bit, depending on rounding) can not be represented.

Examples, for convenience on a decimal base, commonly numbers are on a binary base:

Let's assume you have a signed fixed point defined with 3 digits left of the decimal point and 2 digits right of it.

  • The smallest difference between one value and another is 0.01.

  • The smallest values not equal to zero are -000.01 and +000.01.

  • The largest values are -999.99 and +999.99.

  • Rounding is presumed.

A value like PI will be represented as 3.14, giving an inaccuracy of about 0.05%.

If you try to assign an absolute value smaller than 000.005 it will be represented as 0.

If you try to assign a small value like 0.12345, it will be represented as 0.12, giving an inaccuracy of just about 3%.

If you try to assign a value larger than or equal to 999.995, you can not do this. If your definition knows the concept of overflow, this will be the result.

How are large and small Floating point values represented with Fixed point
how would that number get repressed in fixed point?

Fixed point representation, unlike floating point, is not defined by C nor in the Standard C library.

Fixed point range and precision details are up to the programmer and perhaps by a selected auxiliary fixed-point library.

If an implementation has a floating point unit has small to no impact on floating point encoding and functionality. Of course performance is affected.

An FPU may or may not influence fixed point selection.

Related