00001 #ifndef MATH_OPS_GROUP
00002 #define MATH_OPS_GROUP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020 class math_ops
00021 {
00022 public:
00024 static int round_it(float to_round)
00025 {
00026 int to_return = int(to_round);
00027
00028 if (to_round - float(to_return) > 0.5) to_return++;
00029 return to_return;
00030 }
00031
00033 static int round_it(double to_round)
00034 {
00035 int to_return = int(to_round);
00036
00037 if (to_round - double(to_return) > 0.5) to_return++;
00038 return to_return;
00039 }
00040
00042 static u_int pow_2(const u_int raise_to)
00043 {
00044 if (!raise_to) return 1;
00045 u_int to_return = 2;
00046 for (u_int i = 1; i < raise_to; i++)
00047 to_return *= 2;
00048 return to_return;
00049 }
00050
00052 static u_int factorial(int n)
00053 { return (n < 2)? 1 : n * factorial(n - 1); }
00054 };
00055
00056 #endif
00057