nan gets also returned by things like asin() if you enter an invalied value:
asin(2.0);
(8) Result: nan
here is the interresting part:
asin(2.0)==asin(1.5);
(9) Result: 0
asin(2.0)==asin(2.0);
(10) Result: 0
in mirars example the result was 1.
greetings, martin.