1 #ifndef DOUBLE_PLUS_CLASS
2 #define DOUBLE_PLUS_CLASS
39 #define DEFAULT_DELTA 0.0001
57 { c_value = cp.c_value; c_delta = cp.c_delta;
return *
this; }
61 operator double ()
const {
return truncate(); }
64 double delta()
const {
return c_delta; }
66 void delta(
double new_delta) { c_delta = new_delta; }
75 if (!cast)
return false;
76 return this->d_eq(*cast);
83 if (!cast)
return false;
84 return !this->d_eq(*cast) && (c_value < cast->c_value);
Base class for object that can tell itself apart from other instances.
A base for objects that can be alphabetically (lexicographically) ordered.
void delta(double new_delta)
modifies the precision for equality comparisons.
double truncate() const
returns a version of the number that is chopped off past the delta after rounding.
virtual bool equal_to(const basis::equalizable &f2) const
returns true if this equals "f2" within the "delta" precision.
DEFINE_CLASS_NAME("double_plus")
double_plus(const double_plus &to_copy)
initializes this from "to_copy".
double_plus(double init=0.0, double delta=DEFAULT_DELTA)
initializes using "init" as the initial value and equality within "delta".
virtual bool less_than(const basis::orderable &f2) const
double delta() const
observes the precision for equality comparisons.
double value() const
observes the value held in this.
double_plus & operator=(const double_plus &cp)
standard assignment operator.
static int round_it(float to_round)
returns the rounded integer value for "to_round".
type absolute_value(type a)
Returns a if a is non-negative, and returns -a otherwise.
An extension to floating point primitives providing approximate equality.