Steppable 0.0.1
A CAS project written from scratch in C++
|
Represents a number with arbitrary precision. It basically stores the value as a string. More...
#include <number.hpp>
Public Member Functions | |
Number () | |
The default constructor. Initializes the number with a value of 0. | |
Number (std::string value="0", size_t prec=0, RoundingMode mode=USE_CURRENT_PREC) | |
Initializes a number with a specified value. | |
Number | operator+ (const Number &rhs) const |
Adds two numbers together. | |
Number | operator- (const Number &rhs) const |
Subtracts two numbers. | |
Number | operator* (const Number &rhs) const |
Multiplies two numbers. | |
Number | operator/ (const Number &rhs) const |
Divides two numbers. | |
Number | operator% (const Number &rhs) const |
Calculates the remainder of two numbers. (Modulus) | |
Number | operator^ (const Number &rhs) const |
Raises the number to a power. | |
Number & | operator+= (const Number &rhs) |
Adds the number to another number and assigns the result to the current number. | |
Number & | operator-= (const Number &rhs) |
Subtracts the number from another number and assigns the result to the current number. | |
Number & | operator*= (const Number &rhs) |
Multiplies the number by another number and assigns the result to the current number. | |
Number & | operator/= (const Number &rhs) |
Divides the number by another number and assigns the result to the current number. | |
Number & | operator%= (const Number &rhs) |
Calculates the remainder of two numbers and assigns the result to the current number. | |
Number & | operator^= (const Number &rhs) |
Raises the number to a power and assigns the result to the current number. | |
bool | operator== (const Number &rhs) const |
Compares two numbers for equality. | |
bool | operator!= (const Number &rhs) const |
Compares two numbers for inequality. | |
bool | operator< (const Number &rhs) const |
Compares two numbers for less than. | |
bool | operator> (const Number &rhs) const |
Compares two numbers for greater than. | |
bool | operator<= (const Number &rhs) const |
Compares two numbers for less than or equal to. | |
bool | operator>= (const Number &rhs) const |
Compares two numbers for greater than or equal to. | |
Number | operator++ () |
Increments the number by one. | |
Number | operator-- () |
Decrements the number by one. | |
std::string | present () const |
Presents the number in a human-readable format. | |
Private Attributes | |
std::string | value |
The value of the number. | |
size_t | prec |
The precision of the number. | |
RoundingMode | mode = USE_CURRENT_PREC |
The rounding mode of the number. | |
Represents a number with arbitrary precision. It basically stores the value as a string.
steppable::Number::Number | ( | ) |
The default constructor. Initializes the number with a value of 0.
steppable::Number::Number | ( | std::string | value = "0", |
size_t | prec = 0, | ||
RoundingMode | mode = USE_CURRENT_PREC ) |
Initializes a number with a specified value.
bool steppable::Number::operator!= | ( | const Number & | rhs | ) | const |
Compares two numbers for inequality.
rhs | The number to compare. |
Calculates the remainder of two numbers. (Modulus)
rhs | The number to divide. |
Calculates the remainder of two numbers and assigns the result to the current number.
rhs | The number to divide. |
Multiplies two numbers.
rhs | The number to multiply. |
Multiplies the number by another number and assigns the result to the current number.
rhs | The number to multiply. |
Adds two numbers together.
rhs | The number to add. |
Number steppable::Number::operator++ | ( | ) |
Increments the number by one.
Adds the number to another number and assigns the result to the current number.
rhs | The number to add. |
Subtracts two numbers.
rhs | The number to subtract. |
Number steppable::Number::operator-- | ( | ) |
Decrements the number by one.
Subtracts the number from another number and assigns the result to the current number.
rhs | The number to subtract. |
Divides two numbers.
rhs | The number to divide. |
Divides the number by another number and assigns the result to the current number.
rhs | The number to divide. |
bool steppable::Number::operator< | ( | const Number & | rhs | ) | const |
Compares two numbers for less than.
rhs | The number to compare. |
bool steppable::Number::operator<= | ( | const Number & | rhs | ) | const |
Compares two numbers for less than or equal to.
rhs | The number to compare. |
bool steppable::Number::operator== | ( | const Number & | rhs | ) | const |
Compares two numbers for equality.
rhs | The number to compare. |
bool steppable::Number::operator> | ( | const Number & | rhs | ) | const |
Compares two numbers for greater than.
rhs | The number to compare. |
bool steppable::Number::operator>= | ( | const Number & | rhs | ) | const |
Compares two numbers for greater than or equal to.
rhs | The number to compare. |
Raises the number to a power.
rhs | The power to raise the number to. |
Raises the number to a power and assigns the result to the current number.
rhs | The power to raise the number to. |
|
nodiscard |
Presents the number in a human-readable format.
|
private |
The rounding mode of the number.
|
private |
The precision of the number.
|
private |
The value of the number.