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