rmath.h File Reference

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

Include dependency graph for rmath.h:

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

Go to the source code of this file.

Functions

template<typename T>
static 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>
static 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<>
static const float max_limit< float > ()
 Return the largest possible number that a float may hold.
template<>
static const float min_limit< float > ()
 Return the smallest positive number that a float may hold.
template<>
static const double max_limit< double > ()
 Return the largest possible number that a double may hold.
template<>
static const double min_limit< double > ()
 Return the smallest positive number that a double may hold.
template<typename T>
static const T max_limit (const T &a_arg)
 Return the max_limit of a variable.
template<typename T>
static const T min_limit (const T &a_arg)
 Return the min_limit of a variable.
template<typename T>
static const T highest_value (void)
 Return the maximum possible value a type may hold.
template<typename T>
static const T highest_value (const T &a_arg)
 Return the maximum possible value of a variable.
template<typename T>
static const T lowest_value (void)
 Return 0 for unsigned types, or the maximum negative value that the type may hold.
template<typename T>
static 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>
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.

Referenced by safe_num< T >::add(), safe_num< T >::subtract(), test2(), and test7().

Here is the call graph for this function:

template<typename T>
static 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>
static 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>
static 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>
static 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>
static 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>
static 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.

Referenced by test3(), and vault_manager::usage().

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

Return the largest possible number that a double may hold.

Referenced by test4().

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

Return the largest possible number that a float may hold.

Referenced by test4().

template<typename T>
static 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>
static 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<>
static 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.

Referenced by test4().

template<>
static 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.

Referenced by test4().

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 >::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().

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.

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 Fri Jun 23 16:47:57 2006 for rvm by  doxygen 1.4.2