00001
00018 #ifndef _DECAF_LANG_MATH_H_
00019 #define _DECAF_LANG_MATH_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023
00024 #undef min
00025 #undef max
00026
00027 namespace decaf{
00028 namespace lang{
00029
00035 class DECAF_API Math {
00036 public:
00037
00038 static const double E;
00039 static const double PI;
00040
00041 public:
00042
00043 Math() {}
00044 virtual ~Math() {}
00045
00046 public:
00047
00055 static int abs( int value ) {
00056 return value < 0 ? -value : value;
00057 }
00058
00066 static long long abs( long long value ) {
00067 return value < 0 ? -value : value;
00068 }
00069
00086 static float abs( float value );
00087
00105 static double abs( double value );
00106
00117
00118
00131
00132
00144
00145
00188
00189
00204
00205
00214
00215
00228
00229
00240
00241
00256
00257
00268
00269
00285
00286
00301 static double sqrt( double value );
00302
00319 static double pow( double base, double exp );
00320
00335
00336
00346 static short min( short a, short b ) {
00347 return ( a <= b ? a : b );
00348 }
00349
00359 static int min( int a, int b ) {
00360 return ( a <= b ? a : b );
00361 }
00362
00372 static unsigned int min( unsigned int a, unsigned int b ) {
00373 return ( a <= b ? a : b );
00374 }
00375
00385 static long long min( long long a, long long b ) {
00386 return ( a <= b ? a : b );
00387 }
00388
00401 static float min( float a, float b );
00402
00415 static double min( double a, double b );
00416
00426 static short max( short a, short b ) {
00427 return ( a >= b ? a : b );
00428 }
00429
00439 static int max( int a, int b ) {
00440 return ( a >= b ? a : b );
00441 }
00442
00452 static long long max( long long a, long long b ) {
00453 return ( a >= b ? a : b );
00454 }
00455
00468 static float max( float a, float b );
00469
00481 static double max( double a, double b );
00482
00495
00496
00510
00511
00529
00530
00549 static double ceil( double value );
00550
00566 static double floor( double value );
00567
00585 static int round( float value );
00586
00604 static long long round( double value );
00605
00625
00626
00643 static double random();
00644
00656
00657
00672
00673
00686
00687
00700 static float signum( float value );
00701
00714 static double signum( double value );
00715
00721 static double toRadians( double angdeg ) {
00722 return angdeg / 180 * PI;
00723 }
00724
00730 static double toDegrees( double angrad ) {
00731 return angrad * 180 / PI;
00732 }
00733
00750
00751
00768
00769
00770 };
00771
00772 }}
00773
00774 #endif