MathsCustomFunctions.hpp File Reference

#include <cfloat>
Include dependency graph for MathsCustomFunctions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CompareDoubles

Functions

double SmallPow (double x, unsigned exponent)
unsigned SmallPow (unsigned x, unsigned exponent)
bool Divides (double smallerNumber, double largerNumber)
unsigned CeilDivide (unsigned numerator, unsigned denominator)
double Signum (double value)

Detailed Description

This file contains some utility functions and a small class for dealing with floating point numbers.

Definition in file MathsCustomFunctions.hpp.


Function Documentation

unsigned CeilDivide ( unsigned  numerator,
unsigned  denominator 
)
Returns:
the result of dividing (unsigned) numerator by denominator, rounded up (away from 0), and overflow-safe for large integers up to UINT_MAX.
Parameters:
numerator the numerator
denominator the denominator

Definition at line 137 of file MathsCustomFunctions.cpp.

bool Divides ( double  smallerNumber,
double  largerNumber 
)
Returns:
true if the smaller number divides the larger (to machine precision) Uses fmod to determine if smallerNumber divides the largerNumber. We expect smallerNumber/largerNumber <= 1 and therefore fmod(largerNumber,smallerNumber) should be close to zero or close to smallerNumber.
Parameters:
smallerNumber the smaller
largerNumber the larger

Definition at line 114 of file MathsCustomFunctions.cpp.

double Signum ( double  value  ) 
Returns:
the sign of the argument, i.e. -1 if value<0, 0 if value=0, or +1 if value>0.
Parameters:
value the argument value

Definition at line 150 of file MathsCustomFunctions.cpp.

unsigned SmallPow ( unsigned  x,
unsigned  exponent 
)

Replacement "pow" function for unsigned integer values

Parameters:
x number to be raised to a small power
exponent small integer exponent
Returns:
x^exponent a.k.a x**exponent.

Definition at line 77 of file MathsCustomFunctions.cpp.

double SmallPow ( double  x,
unsigned  exponent 
)

Replacement "pow" function.

Parameters:
x number to be raised to a small power
exponent small integer exponent
Returns:
x^exponent a.k.a x**exponent.

Definition at line 41 of file MathsCustomFunctions.cpp.


Generated by  doxygen 1.6.2