rmath.h File Reference

#include <string>
#include <float.h>
#include "asserts.h"
#include "types.h"
#include "estring.h"

Include dependency graph for rmath.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Classes

class  safe_num
 Safely manipulate numbers without worryiung about over/underflow error. More...


Functions

template<typename T> const T max_limit ()
 Find the maximum limit for a type, equivalent to std::numeric_limits<T>.max() for systems that don't have the limits c++ header file.

template<typename T> const T min_limit ()
 Find the maximum limit for a type, equivalent to std::numeric_limits<T>.min() for systems that don't have the limits c++ header file.

template<> const float max_limit< float > ()
 Return the largest possible number that a float may hold.

template<> const float min_limit< float > ()
 Return the smallest positive number that a float may hold.

template<> const double max_limit< double > ()
 Return the largest possible number that a double may hold.

template<> const double min_limit< double > ()
 Return the smallest positive number that a double may hold.

template<typename T> const T max_limit (const T &a_arg)
 Return the max_limit of a variable.

template<typename T> const T min_limit (const T &a_arg)
 Return the min_limit of a variable.

template<typename T> const T highest_value (void)
 Return the maximum possible value a type may hold.

template<typename T> const T highest_value (const T &a_arg)
 Return the maximum possible value of a variable.

template<typename T> const T lowest_value (void)
 Return 0 for unsigned types, or the maximum negative value that the type may hold.

template<typename T> const T lowest_value (const T &a_arg)
 Return 0 for unsigned types, or the maximum negative value that a variable may hold.

template<typename T> T absolute (const T &a_num)
 Return the absolute value of a numeric type.

template<typename T> safe_num< T > operator+ (safe_num< T > a_class1, safe_num< T > a_class2)
 Arithmetic operator.

template<typename T> safe_num< T > operator- (safe_num< T > a_class1, safe_num< T > a_class2)
 Arithmetic operator.

template<typename T> safe_num< T > operator * (safe_num< T > a_class1, safe_num< T > a_class2)
 Arithmetic operator.

template<typename T> safe_num< T > operator/ (safe_num< T > a_class1, safe_num< T > a_class2)
 Arithmetic operator.

template<typename T> safe_num< T > operator% (safe_num< T > a_class1, safe_num< T > a_class2)
 Arithmetic operator.

template<typename T> safe_num< T > & operator++ (safe_num< T > &a_class)
 Arithmetic operator.

template<typename T> safe_num< T > operator++ (safe_num< T > &a_class, int)
 Arithmetic operator.

template<typename T> safe_num< T > & operator-- (safe_num< T > &a_class)
 Arithmetic operator.

template<typename T> safe_num< T > operator-- (safe_num< T > &a_class, int)
 Arithmetic operator.

template<typename T> std::ostream & operator<< (std::ostream &a_out, safe_num< T > a_class)
 Arithmetic operator.

template<typename T> std::istream & operator>> (std::istream &a_in, safe_num< T > &a_class)
 Arithmetic operator.


Function Documentation

template<typename T>
T absolute const T &  a_num  ) 
 

Return the absolute value of a numeric type.

Caveat: For some types, the maximum negative value is one larger than the maximum positive value: specifically char. Depending on the type and value, it may be impossible to return the absolute value. For such types under such circumstances an exception is thrown.

Definition at line 220 of file rmath.h.

References INTERNAL_ERROR, is_char(), and TRY_nomem.

Here is the call graph for this function:

template<typename T>
const T highest_value const T &  a_arg  )  [static]
 

Return the maximum possible value of a variable.

Definition at line 173 of file rmath.h.

template<typename T>
const T highest_value void   )  [static]
 

Return the maximum possible value a type may hold.

This is just a convenience function to match lowest_value<T>(). All it does is return the value of max_limit<T>().

Definition at line 162 of file rmath.h.

template<typename T>
const T lowest_value const T &  a_arg  )  [static]
 

Return 0 for unsigned types, or the maximum negative value that a variable may hold.

Definition at line 201 of file rmath.h.

template<typename T>
const T lowest_value void   )  [static]
 

Return 0 for unsigned types, or the maximum negative value that the type may hold.

Definition at line 186 of file rmath.h.

template<typename T>
const T max_limit const T &  a_arg  )  [static]
 

Return the max_limit of a variable.

This is handy to have because it means that the author may change the type of a variable without having to track down all uses of max_limit or min_limit to change the type they measure.

Definition at line 129 of file rmath.h.

template<typename T>
const T max_limit  )  [static]
 

Find the maximum limit for a type, equivalent to std::numeric_limits<T>.max() for systems that don't have the limits c++ header file.

Definition at line 20 of file rmath.h.

template<>
const double max_limit< double >  )  [static]
 

Return the largest possible number that a double may hold.

template<>
const float max_limit< float >  )  [static]
 

Return the largest possible number that a float may hold.

template<typename T>
const T min_limit const T &  a_arg  )  [static]
 

Return the min_limit of a variable.

This is handy to have because it means that the author may change the type of a variable without having to track down all uses of max_limit or min_limit to change the type they measure.

Definition at line 145 of file rmath.h.

template<typename T>
const T min_limit  )  [static]
 

Find the maximum limit for a type, equivalent to std::numeric_limits<T>.min() for systems that don't have the limits c++ header file.

Definition at line 48 of file rmath.h.

template<>
const double min_limit< double >  )  [static]
 

Return the smallest positive number that a double may hold.

Caveat: This is in contrast to other types, where min_limit<T>() will return either 0 or the largest possible negative number that the type may hold. If you are looking for the largest possible negative number for any given type, use lowest_value<T>() instead.

template<>
const float min_limit< float >  )  [static]
 

Return the smallest positive number that a float may hold.

Caveat: This is in contrast to other types, where min_limit<T>() will return either 0 or the largest possible negative number that the type may hold. If you are looking for the largest possible negative number for any given type, use lowest_value<T>() instead.

template<typename T>
safe_num<T> operator * safe_num< T >  a_class1,
safe_num< T >  a_class2
 

Arithmetic operator.

Definition at line 687 of file rmath.h.

References safe_num< T >::assign(), and safe_num< T >::multiply().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator% safe_num< T >  a_class1,
safe_num< T >  a_class2
 

Arithmetic operator.

Definition at line 711 of file rmath.h.

References safe_num< T >::assign(), and safe_num< T >::value().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator+ safe_num< T >  a_class1,
safe_num< T >  a_class2
 

Arithmetic operator.

Definition at line 663 of file rmath.h.

References safe_num< T >::add(), and safe_num< T >::assign().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator++ safe_num< T > &  a_class,
int 
 

Arithmetic operator.

Definition at line 731 of file rmath.h.

References safe_num< T >::add(), and safe_num< T >::assign().

Here is the call graph for this function:

template<typename T>
safe_num<T>& operator++ safe_num< T > &  a_class  ) 
 

Arithmetic operator.

Definition at line 722 of file rmath.h.

References safe_num< T >::add().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator- safe_num< T >  a_class1,
safe_num< T >  a_class2
 

Arithmetic operator.

Definition at line 675 of file rmath.h.

References safe_num< T >::assign(), and safe_num< T >::subtract().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator-- safe_num< T > &  a_class,
int 
 

Arithmetic operator.

Definition at line 752 of file rmath.h.

References safe_num< T >::assign(), and safe_num< T >::subtract().

Here is the call graph for this function:

template<typename T>
safe_num<T>& operator-- safe_num< T > &  a_class  ) 
 

Arithmetic operator.

Definition at line 743 of file rmath.h.

References safe_num< T >::subtract().

Here is the call graph for this function:

template<typename T>
safe_num<T> operator/ safe_num< T >  a_class1,
safe_num< T >  a_class2
 

Arithmetic operator.

Definition at line 699 of file rmath.h.

References safe_num< T >::assign(), and safe_num< T >::divide().

Here is the call graph for this function:

template<typename T>
std::ostream& operator<< std::ostream &  a_out,
safe_num< T >  a_class
 

Arithmetic operator.

Definition at line 764 of file rmath.h.

template<typename T>
std::istream& operator>> std::istream &  a_in,
safe_num< T > &  a_class
 

Arithmetic operator.

Definition at line 773 of file rmath.h.


Generated on Mon Jul 12 12:04:39 2004 for rvm by doxygen 1.3.6