00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GV_ARITH_H
00021 #define GV_ARITH_H
00022
00023
00024 #ifndef _GNU_SOURCE
00025 #define _GNU_SOURCE 1
00026 #endif
00027 #ifdef HAVE_LIMITS_H
00028 #include <limits.h>
00029 #else
00030 #ifdef HAVE_VALUES_H
00031 #include <values.h>
00032 #endif
00033 #endif
00034 #include <math.h>
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040 #ifdef MIN
00041 #undef MIN
00042 #endif
00043 #define MIN(a,b) ((a)<(b)?(a):(b))
00044
00045 #ifdef MAX
00046 #undef MAX
00047 #endif
00048 #define MAX(a,b) ((a)>(b)?(a):(b))
00049
00050 #ifdef ABS
00051 #undef ABS
00052 #endif
00053 #define ABS(a) ((a) >= 0 ? (a) : -(a))
00054
00055 #ifndef INT_MAX
00056 #define INT_MAX ((int)(~(unsigned)0 >> 1))
00057 #endif
00058
00059 #ifndef INT_MIN
00060 #define INT_MIN (-INT_MAX - 1)
00061 #endif
00062
00063 #ifndef MAXSHORT
00064 #define MAXSHORT (0x7fff)
00065 #endif
00066
00067 #ifndef MAXDOUBLE
00068 #define MAXDOUBLE 1.7976931348623157e+308
00069 #endif
00070
00071 #ifndef MAXFLOAT
00072 #define MAXFLOAT ((float)3.40282347e+38)
00073 #endif
00074
00075 #ifdef BETWEEN
00076 #undef BETWEEN
00077 #endif
00078 #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c)))
00079
00080 #ifndef M_PI
00081 #define M_PI 3.14159265358979323846
00082 #endif
00083
00084 #ifndef SQRT2
00085 #define SQRT2 1.41421356237309504880
00086 #endif
00087
00088 #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5))
00089 #define RADIANS(deg) ((deg)/180.0 * M_PI)
00090 #define DEGREES(rad) ((rad)/M_PI * 180.0)
00091
00092 #define SQR(a) ((a) * (a))
00093
00094 #ifdef HAVE_SINCOS
00095 extern void sincos(double x, double *s, double *c);
00096 #else
00097 # define sincos(x,s,c) *s = sin(x); *c = cos(x)
00098 #endif
00099
00100 #ifdef __cplusplus
00101 }
00102 #endif
00103
00104 #endif