math and cosinus

Hy

Hmm I like to calculate the cos-1() but when I use acos the result is wrong.
So: cos-1(500/1000) => 60° the Arduino does calculate 90° why?

This is the code:

float alpha = acos(500/1000);
int grad = alpha*57.2957795131; //is the same as (180/pi)
Serial.println(grad);

What am I doing wrong?

THx
Andy

acos(500/1000);

is the same as

acos(0);

Try:acos(500.0/1000.0);

ahhhhh sorry for that but how could I miss that!!!

Thx a lot you saved me a lot of time :slight_smile: