cancel
Showing results for 
Search instead for 
Did you mean: 

Small Floating point values

ZHaid.1
Associate II

Hi,

I have a general question regarding the problem I am facing.

Currently, the pSpeed Value is very small (for example 3.4E-7) and when I perform a square for such values it becomes smaller. When I pass the Square data value to the arm_sqrt_f32() function, the value is correct when I have small values in the pSpeed array.

To resolve it I Multiplied the Speed array values by 1000 and then divided the speed Value by 100 at the end and now my values become accurate as per the Excel sheet value (I passed those raw values to Excel to verify my results)

I assume that arm_sqrt_f32() is rounding up the value because of squareData. Is it correct?
If yes then I can safely use the technique of multiplying and dividing by 1000 or someone can help with any other strategy

I would appreciate help in this regard

 

ZHaid1_0-1702573772577.png

 

4 REPLIES 4
TDK
Guru

What chip? If it has an FPU, it will be faster to use native sqrt functions.

 

If you feel a post has answered your question, please click "Accept as Solution".

>>When I pass the Square data value to the arm_sqrt_f32() function, the value is correct when I have small values in the pSpeed array.

Did you mean to say that it's incorrect for very small values?

Please show specific examples of inputs vis outputs, and the error as you square and subtract from the initial value

Which STM32 and CMSIS-DSP library version?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

What chip?

STM32L4R9ZIJ6

If it has an FPU, it will be faster to use native sqrt functions

Yes, it has FPU. Thanks for the suggestion. I will use sqrtf() and will get back to you with the results

Did you mean to say that it's incorrect for very small values?

Yes. Sorry for the typo. I have updated my post now

Please show specific examples of inputs vis outputs, and the error as you square and subtract from the initial value

I have an array of float for 512 speed values we only use 256 values for calculating Speed RMS

Example Values are:

1.99908E-06, 3.61418E-06, 5.22994E-07, 1.18181E-06, 2.86142E-06

With square, the values become too much small, and the RMS value becomes incorrect by comparing the Speed RMS calculated by Excel. Keeping Speed Array data constant

Which STM32 and CMSIS-DSP library version?

STM32L4R9ZIJ6