Hi,
What should I do to avoid nan result of calculation?
Here is what I am doing:
Serial.print (sqrt((0-110)*(0-110)+(0-110)*(0-110)+(0-110)*(0-110)));
This is printing nan.
Same thing in Eclipse return actual number: 190.526
Thanks.
Hi,
What should I do to avoid nan result of calculation?
Here is what I am doing:
Serial.print (sqrt((0-110)*(0-110)+(0-110)*(0-110)+(0-110)*(0-110)));
This is printing nan.
Same thing in Eclipse return actual number: 190.526
Thanks.
Well, both the intermediate products and the final sum before taking the root are values that won't fit in a 16 bit int.
Try declaring them as floats, or giving them all ".0", and see what that does for you.
Lose the "sqrt()" in your print, and all will be revealed
one float saves the day...
Serial.println (sqrt((0 - 110.0) * (0 - 110) + (0 - 110) * (0 - 110) + (0 - 110) * (0 - 110)));
Hi, you are correct, I was out of range.
Thank you.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.