2018-07-30 05:59 AM
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...
Solved! Go to Solution.
2018-07-31 04:56 PM
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.
2018-07-31 05:57 PM
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.
2018-07-31 06:08 PM
"I could have used 4 if statements, maybe a little faster."
LUT.