problems with sqrt() function

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problems with sqrt() function

2,448 Views
Franklin
Contributor I
I am trying to do the following calculation
 
              location[3] = isqrt((dist_3^2)-((location[1])^2)-(location[2])^2);
 
and I get
 
Error C1826: Integer-expression expected
Error C5002: Illegal type
Error C1829: +- Incompatible types
 
among others.
 
"location" is a double, and "dist_3" is an int.
I put a line, #include "math.h" at the top of my code...
Labels (1)
Tags (1)
0 Kudos
Reply
3 Replies

885 Views
kef
Specialist I


 
              location[3] = isqrt((dist_3^2)-((location[1])^2)-(location[2])^2);
 

 

XORing with double is something :smileyhappy:

 

Regards



Message Edited by kef on 2008-05-30 11:51 PM
0 Kudos
Reply

885 Views
CompilerGuru
NXP Employee
NXP Employee
To compute the square, multiply it with itself,
dist_3^2 does toggle the second last bit :smileyhappy:.
So try dist_3*dist_3 instead.

Daniel

885 Views
Lundin
Senior Contributor IV
There is also the pow() function which works for float numbers.