trunc() is normally in math.h

This commit is contained in:
Glenn Maynard
2003-02-15 00:35:44 +00:00
parent cbadeb046f
commit 44c42ca0e1
+4
View File
@@ -104,7 +104,11 @@ inline float randomf( const float low=-1.0f, const float high=1.0f )
/* XXX: These are C99 functions (except for the roundf(double) overload); what's
* the C99 define we can test for? */
#if defined(WIN32)
inline double trunc( double f ) { return float(int(f)); };
#else
#include <math.h>
#endif
inline float truncf( float f ) { return float(int(f)); };
inline float roundf( float f ) { if(f < 0) return truncf(f-0.5f); return truncf(f+0.5f); };
inline double roundf( double f ){ if(f < 0) return trunc(f-0.5); return trunc(f+0.5); };