Main Page | Class List | File List | Class Members | File Members

junkmath.h

00001 /* Workarounds for missing ISO C99 math functions, etc.
00002  *
00003  * $Id: junkmath.h,v 1.2 2004/11/09 12:46:58 mmunro Exp $
00004  */
00005 
00006 #ifndef JUNKMATH_H
00007 #define JUNKMATH_H 1
00008 
00009 #ifndef M_PI
00010 #define M_PI  3.14159265358979323846  /* pi (to double precision) */
00011 #endif /* ! defined(M_PI) */
00012 
00013 #ifndef M_PI_2
00014 #define M_PI_2  1.57079632679489661923  /* pi/2 (to double precision) */
00015 #endif /* ! defined(M_PI_2) */
00016 
00017 #if (!defined __USE_ISOC99 && !defined _ISOC99_SOURCE && \
00018      !defined _ISOC9X_SOURCE && !(defined __STDC_VERSION__ && \
00019                                   (__STDC_VERSION__ >= 199901L)))
00020 /* Not using C99 source . . . */
00021 
00022 static double fmax(double a, double b)
00023 {
00024   return (a > b) ? a : b;
00025 }
00026 
00027 static double fmin(double a, double b)
00028 {
00029   return (a < b) ? a : b;
00030 }
00031 /*
00032 static long double atanl(long double t)
00033 {
00034   return (long double)atan((double)t);
00035 }
00036 
00037 static long double atan2l(long double s, long double t)
00038 {
00039   return (long double)atan2((double)s, (double)t);
00040 }
00041 */
00042 static double round(double x)
00043 {
00044   double a, ip;
00045 
00046   a = modf (x, &ip);
00047   if (a <= (-0.5))
00048     return ip - 1;
00049   else if (a >= 0.5)
00050     return ip + 1;
00051   else
00052     return ip;
00053 }
00054 #endif /* Not using C99 source */
00055 
00056 #endif /* !JUNKMATH_H */

Generated on Sat Dec 4 17:12:11 2004 for trees by  doxygen 1.3.9.1