Canola
0.8.D001
|
#include <precision_and_rounding.h>
Public Types | |
enum | round_t { round_up, round_off, round_down } |
Public Member Functions | |
virtual | ~precision_and_rounding () |
precision_and_rounding () | |
precision_and_rounding (int precision, round_t round) | |
precision_and_rounding (const precision_and_rounding &rhs) | |
precision_and_rounding & | operator= (const precision_and_rounding &rhs) |
void | apply (number &value) |
int | get_precision (void) const |
round_t | get_rounding (void) const |
Private Attributes | |
int | precision |
round_t | round |
The precision_and_rounding class is used to represent the setting of the Decimal Point Selector Dial and Rounding Switch. These are always applied together.
Definition at line 28 of file precision_and_rounding.h.
round_up |
round away from zero |
round_off |
round towards the closest integer. |
round_down |
round towards zero |
Definition at line 41 of file precision_and_rounding.h.
precision_and_rounding::~precision_and_rounding | ( | ) | [virtual] |
The destructor.
Definition at line 24 of file precision_and_rounding.cc.
The default constructor.
Definition at line 29 of file precision_and_rounding.cc.
precision_and_rounding::precision_and_rounding | ( | int | precision, |
round_t | round | ||
) |
A constructor.
precision | the number of decimal places of precision (places to the rigth of the decimal point). |
round | the rounding direction. |
Definition at line 38 of file precision_and_rounding.cc.
The copy constructor.
rhs | The right hand side of the initialization. |
Definition at line 48 of file precision_and_rounding.cc.
void precision_and_rounding::apply | ( | number & | value | ) |
The apply method is used to apply this precision and rounding to a number value.
value | The value to be rounded. |
Definition at line 70 of file precision_and_rounding.cc.
int precision_and_rounding::get_precision | ( | void | ) | const [inline] |
Definition at line 95 of file precision_and_rounding.h.
round_t precision_and_rounding::get_rounding | ( | void | ) | const [inline] |
Definition at line 97 of file precision_and_rounding.h.
precision_and_rounding & precision_and_rounding::operator= | ( | const precision_and_rounding & | rhs | ) |
The assignment operator.
rhs | The right hand side of the assignment. |
Definition at line 58 of file precision_and_rounding.cc.
int precision_and_rounding::precision [private] |
The precision instance variable is used to remember the number of decimal places of precision (places to the rigth of the decimal point), or -1 for floating point.
Definition at line 105 of file precision_and_rounding.h.
round_t precision_and_rounding::round [private] |
The round instance variable is used to remember the rounding direction.
Definition at line 111 of file precision_and_rounding.h.