Sqrt function odness

using Fiji v1.52p

Anyone who can tell me why in fiji macro language

distance = sqrt((X-X1)^2 +(Y-Y1)^2);

returns NaN eventhough ((X-X1)^2 +(Y-Y1)^2) gives a valid (float) number as a result.

and

distance = sqrt((X-X1)(X-X1)+(Y-Y1)(Y-Y1));

correctly calculates the distance?

the latter works but distresses my OCD person.

KR

Jan

Hi
@jansoetaert

Two indications:
1;
https://imagej.nih.gov/ij/developer/macro/functions.html#P

pow(base, exponent)
Returns the value of base raised to the power of exponent .
2;

1 Like

thanks Mathew,

pow seems to work!

i will nick the function idea as that tidies things up as well!

kr

Jan