problems with sqrt() function

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

problems with sqrt() function

3,131 次查看
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...
标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,568 次查看
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 项奖励
回复

1,568 次查看
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

1,568 次查看
Lundin
Senior Contributor IV
There is also the pow() function which works for float numbers.