I have an stm32-F1 processor that is very slow with float operations and I have some libraries from an F7 processor that uses a lot of floats. I would like to use this libraries on my poor F1 so I was thinking of a way to make as less tweaks as I can on the code and emulate floats with a same interface but with an underling integer type.It's important to note that I only need 7 digits of accuracy (numbers between 0.001 and 4094.999 that's why I guess something like typedef number<cpp_dec_float<7> > fixed7;
would work in my case faster than floats.
Is boost's multiprescision good enough for that ? Do you have any other suggestions? should I make my own arithmetic type?
Asked
Active
Viewed 152 times
0

Spyros Mourelatos
- 484
- 1
- 8
- 19
-
What is the desired magnitude? Specifying only a digit count is not enough for fixed-point, as the scale is fixed and chosen by you (that's what makes the point in fixed-point, well, fixed). Should it be decimal fixed-point, or binary? (binary helps to make multiplication efficient, doesn't matter for addition) – harold Mar 27 '20 at 16:30
-
@harold You are right I have both additions and multiplications so I guess decimal fixed point , my range of interest is 0.001 to 4094.999 so I was wrong saying I only need three to four digits, I need 7 digits of accuracy – Spyros Mourelatos Mar 28 '20 at 08:59
-
for 3 digits of precision you need at least 10 fractional bits. That means anything from Q22.10 to Q12.20 – phuclv Mar 28 '20 at 10:01
1 Answers
0
I found a solution after all. Τhis numeric system is excellent for my purpose and a little simpler to use as multiprescision
is based on having higher accuracy than normal c++ but I just want less precision. Here is John's MC Farlane numeric types

Spyros Mourelatos
- 484
- 1
- 8
- 19