problems with sqrt() function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

problems with sqrt() function

3,133件の閲覧回数
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,570件の閲覧回数
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,570件の閲覧回数
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,570件の閲覧回数
Lundin
Senior Contributor IV
There is also the pow() function which works for float numbers.