cancel
Showing results for 
Search instead for 
Did you mean: 

How fast is a double floating point Square root function on a 48MHz Cortex M0 ?

T J
Lead

I made an integer Square root function:

   int integerSQRT, result,result2;

   for (integerSQRT = 0; integerSQRT < 100; integerSQRT++)

       if (integerSQRT*integerSQRT >= squaredResult) {           

           result = integerSQRT - 1;      // just larger than the sqroot -1 is just less than

           integerSQRT = 100;

       }

   

// easily adapted to cube root, quad root etc...

12 REPLIES 12
henry.dick
Senior II

if you really want to know, double precision sqrt takes about 1000 ticks (-O1), and single precision sqrt 500 ticks (-O1), on the same chip, inclusive of overhead.

you can get your code to a working order and then we can make a more fair comparison.

T J
Lead

that part of the code is finished... working on LinearTouch

To calculate the Y coordinate on a triangle shaped sensor, I needed the Sqrt function twice

but only needs to resolve from 4 bits ( max value is 30) Sqrt is 5.

I could have used 4 if statements, maybe a little faster.

henry.dick
Senior II

"I could have used 4 if statements, maybe a little faster."

LUT.