Added explicit type conversions to remove warnings when using strict warning settings.
Used MAX instead of fmax so that we are not converting between doubles and floats on 64-bit builds.
Reverted to fmax using tgmath.h to handle 64-bit builds.