Canola
0.8.D001
|
#include <number.h>
Public Member Functions | |
~number () | |
number () | |
number (const number &rhs) | |
number (long rhs) | |
number & | operator= (const number &rhs) |
void | operator+= (const number &rhs) |
number | operator+ (const number &rhs) const |
void | operator-= (const number &rhs) |
number | operator- (const number &rhs) const |
number | operator- (void) const |
void | operator*= (const number &rhs) |
number | operator* (const number &rhs) const |
void | operator/= (const number &rhs) |
number | operator/ (const number &rhs) const |
number | sqrt (void) const |
long | to_long (void) const |
number | round_up (int preferred_decimal) const |
number | round_off (int preferred_decimal) const |
number | round_down (int preferred_decimal) const |
std::string | to_string (void) const |
display | get_display (void) const |
void | right_shift (void) |
bool | operator== (const number &rhs) const |
bool | operator!= (const number &rhs) const |
bool | operator< (const number &rhs) const |
bool | operator<= (const number &rhs) const |
bool | operator> (const number &rhs) const |
bool | operator>= (const number &rhs) const |
int | sign (void) const |
number | fabs (void) const |
void | insert_digit_before_dot (int n) |
void | insert_digit_after_dot (int n) |
void | insert_dot (void) |
bool | has_overflowed (void) const |
Static Public Member Functions | |
static number | infinity (void) |
Private Member Functions | |
void | clear (void) |
bool | is_zero (void) const |
void | print_me (const char *file, int line) const |
number (const number_z &value, unsigned decimal, bool negative=false) | |
Static Private Member Functions | |
static unsigned | max (unsigned a, unsigned b) |
static int | max (int a, int b) |
static number | positive_minus_positive (const number &lhs, const number &rhs) |
static number | positive_plus_positive (const number &lhs, const number &rhs) |
static void | truncate_floating_operation (number_z &t3, unsigned &t3ndec) |
static void | strip_redundant_decimal_places (number_z &t3, unsigned &t3ndec) |
Private Attributes | |
number_z | value |
unsigned | decimal |
bool | negative |
The number class is used to represent the values used by the calculator to perform arithmetic. It is limited to 16 digits, and a decimal point placed somewhere in those 16 digits. The minus sign is separate. The overflow bit indicates carry into the nonexistent next digit.
number::~number | ( | ) |
number::number | ( | ) |
The default constructor. Value is zero.
Definition at line 21 of file constructor_default.cc.
number::number | ( | const number & | rhs | ) |
The copy constructor.
rhs | The right hand side of the initialization. |
Definition at line 21 of file constructor_copy.cc.
number::number | ( | long | rhs | ) |
A constructor.
rhs | The right hand side of the initialization. |
Definition at line 21 of file constructor_long.cc.
number::number | ( | const number_z & | value, |
unsigned | decimal, | ||
bool | negative = false |
||
) | [private] |
A constructor.
value | The underlying integer value. |
decimal | The number of decimal places. |
negative | Whether or not the number is negative. |
Definition at line 21 of file constructor3.cc.
void number::clear | ( | void | ) | [private] |
number number::fabs | ( | void | ) | const |
display number::get_display | ( | void | ) | const |
The get_display method may be used to obtain a representation of this number in a form suitable for displaying on the calculator front panel.
Definition at line 24 of file get_display.cc.
bool number::has_overflowed | ( | void | ) | const |
The has_overflowed method may be used to determine whether or not this numeric value is too large to fit on the 1614P's display.
Definition at line 22 of file has_overflowed.cc.
number number::infinity | ( | void | ) | [static] |
The infinity class member may be used to create a value that has overflowed, for use when division by zero occurs (and probably some other cases I haven't found yet).
Definition at line 22 of file infinity.cc.
void number::insert_digit_after_dot | ( | int | n | ) |
void number::insert_digit_before_dot | ( | int | n | ) |
void number::insert_dot | ( | void | ) |
bool number::is_zero | ( | void | ) | const [private] |
The is_zero method is used to determine whether or not this number is exactly zero.
Definition at line 22 of file is_zero.cc.
static unsigned number::max | ( | unsigned | a, |
unsigned | b | ||
) | [inline, static, private] |
static int number::max | ( | int | a, |
int | b | ||
) | [inline, static, private] |
bool number::operator!= | ( | const number & | rhs | ) | const |
The miltiplication operator may be used to multiply two numbers together.
rhs | The right hand side of the multiplication. |
Definition at line 31 of file multiplication.cc.
void number::operator*= | ( | const number & | rhs | ) |
The multiply-in-situ operator may be used to multiply this number by another number.
rhs | The right hand side of the multiplication. |
Definition at line 24 of file multiplication.cc.
The addition operator may be used to add two numbers together.
rhs | The right hand side of the addition. |
Definition at line 31 of file addition.cc.
void number::operator+= | ( | const number & | rhs | ) |
The add-in-situ operator may be used to add another number to this number.
rhs | The right hand side of the addition. |
Definition at line 24 of file addition.cc.
The subtraction operator may be used to add subtract one number from another.
rhs | The right hand side of the subtraction. |
Definition at line 31 of file subtraction.cc.
number number::operator- | ( | void | ) | const |
The negative operator may be used to invert the sign of a number.
Definition at line 22 of file negative.cc.
void number::operator-= | ( | const number & | rhs | ) |
The subtract-in-situ operator may be used to subtract another number from this number.
rhs | The right hand side of the subtraction. |
Definition at line 24 of file subtraction.cc.
The division operator may be used to divide on number by aother.
rhs | The right hand side of the division. |
Definition at line 32 of file division.cc.
void number::operator/= | ( | const number & | rhs | ) |
The divide-in-situ operator may be used to divide this number by another number.
rhs | The right hand side of the division. |
Definition at line 25 of file division.cc.
bool number::operator< | ( | const number & | rhs | ) | const |
bool number::operator<= | ( | const number & | rhs | ) | const |
The assignment operator.
rhs | The right hand side of the assignment. |
Definition at line 22 of file assignment.cc.
bool number::operator== | ( | const number & | rhs | ) | const |
bool number::operator> | ( | const number & | rhs | ) | const |
bool number::operator>= | ( | const number & | rhs | ) | const |
number number::positive_minus_positive | ( | const number & | lhs, |
const number & | rhs | ||
) | [static, private] |
The positive_minus_positive class method is used to subtract two positive numbers. This is a helper function for the operator+ and operator- methods.
Definition at line 24 of file positive_minus_positive.cc.
number number::positive_plus_positive | ( | const number & | lhs, |
const number & | rhs | ||
) | [static, private] |
The positive_plus_positive class method is used to add two positive numbers. This is a helper function for the operator+ and operator- methods.
Definition at line 24 of file positive_plus_positive.cc.
void number::print_me | ( | const char * | file, |
int | line | ||
) | const [private] |
The print_me method is used to print a representation of the number on stderr. This is for use when debugging.
file | The source file, use the __FILE__ macro. |
line | The source line, use the __LINE__ macro. |
Definition at line 24 of file print_me.cc.
void number::right_shift | ( | void | ) |
The right_shift method may be used to shift all of the digits of thenumber one place to the right, discarding the right most digit. If there are any decimal places, they are reduced by one. This is done in situ.
Definition at line 24 of file right-shift.cc.
number number::round_down | ( | int | preferred_decimal | ) | const |
number number::round_off | ( | int | preferred_decimal | ) | const |
number number::round_up | ( | int | preferred_decimal | ) | const |
int number::sign | ( | void | ) | const |
number number::sqrt | ( | void | ) | const |
void number::strip_redundant_decimal_places | ( | number_z & | t3, |
unsigned & | t3ndec | ||
) | [static, private] |
The strip_redundant_decimal_places class method is used to remove zero digits on the right, if they are to the right of the decimal point.
Definition at line 22 of file strip_redundant_decimals.cc.
long number::to_long | ( | void | ) | const |
The to_long method is used to extract the integer part of the number into a C long value. If the value would overflow, LONG_MAX or -LONG_MAX will be returned.
Definition at line 22 of file to_long.cc.
std::string number::to_string | ( | void | ) | const |
The to_string method may be used to form a textual representation of this number.
Definition at line 22 of file to_string.cc.
void number::truncate_floating_operation | ( | number_z & | t3, |
unsigned & | t3ndec | ||
) | [static, private] |
The truncate_floating_operation class method is used to adjust the number of decimal places of an answer, so that it will fit on the 1614P's display.
Definition at line 36 of file truncate_floating_operation.cc.
unsigned number::decimal [private] |
bool number::negative [private] |
number_z number::value [private] |