MathsCustomFunctions.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MATHSCUSTOMFUNCTIONS_HPP_
00030 #define MATHSCUSTOMFUNCTIONS_HPP_
00031
00032 #include <cfloat>
00033
00047 double SmallPow(double x, unsigned exponent);
00048
00057 bool Divides(double smallerNumber, double largerNumber);
00058
00063 class CompareDoubles
00064 {
00065 public:
00073 static bool IsNearZero(double number, double tolerance);
00074
00082 static bool WithinRelativeTolerance(double number1, double number2, double tolerance);
00083
00092 static bool WithinAbsoluteTolerance(double number1, double number2, double tolerance);
00093
00103 static bool WithinTolerance(double number1, double number2, double tolerance, bool toleranceIsAbsolute);
00104
00115 static bool WithinAnyTolerance(double number1, double number2,
00116 double relTol=DBL_EPSILON, double absTol=DBL_EPSILON,
00117 bool printError=false);
00118
00126 static double Difference(double number1, double number2, bool toleranceIsAbsolute);
00127 };
00128
00129 #endif