# How to fix point?

• posted

My question is, how do know what value to multiply the floating point value to? I have a desktop application that shifts a float to 20 bits (n

• posted

Just look at the possible parameters to printf. Or sprintf.

```--

```
• posted

First, I imagine that you can implement double precision with a DSP if you need to.

Choosing the scale factor for fixed point is a tradeoff between range, precision, and number of bits. Divide the maximum integer value by the maximum data value to get the maximum scale factor. From your values, if you want to represent them in a signed 16-bit value, the maximum scale factor is 32767/8.234526 = 3979.22. Scale factors are often a power of 2 or power of 10, but don't have to be. A scale factor of 2048 would suffice. With that scale factor, you have a resolution of 1/2048 = 0.000488, giving approximately 3 1/3 digits to the right of the decimal point. What type of quantity are you representing?

```--
• posted

Depends on the least significant digit which needs to be accurate.

To represent 8.... you need as noted before 2048 as scale-factor (assuming shifting is the preferred way).

The boundary values will have an error below 1/1000 but what about the steps in between ?

I´d go for two 16bit registers, using 16bit fixed point (no shifting needed).

```--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)```
• posted

They will also have an error below 1/2048.

The requirement for the extra precision depends on the application.

```--