> double a = atof("NAN");
atof does not detect errors. tonumber does.
>$ ./t
>0 0 0 1 0 0
It seems that your atof accepts "NAN" and returns IEEE NaN.
In general, atof is not required by ANSI C to do so and will return 0 instead.
The output of your program would then be
0 1 1 0 1 0
which is what it does in my Linux.
--lhf