slembcke/Chipmunk-Physics — pull request #31 by pbhogan (2013-01-13 16:23:17+00:00)
Title: Fix for broken NaN check.

I was looking at code in cpBody.h, specifically cpBodyKineticEnergy, and if I'm reading it right you're trying to do a boolean check to see if vsq and wsq are NaNs. My understanding is that NaN always evaluates to boolean true making these checks broken.

Here's some additional info: http://stackoverflow.com/a/9159641

I'm submitting a fix with isnan(), which is a C99 macro. You could also use the (x != x) trick, but I've seen some say that breaks under g++ with -ffast-math.

You could probably throw in
#ifndef isnan
#define isnan(x) (x != x)
#endif
and cover more ground.