Steppable 0.0.1
A CAS project written from scratch in C++
Loading...
Searching...
No Matches
steppable::Number Class Reference

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.
 
Numberoperator+= (const Number &rhs)
 Adds the number to another number and assigns the result to the current number.
 
Numberoperator-= (const Number &rhs)
 Subtracts the number from another number and assigns the result to the current number.
 
Numberoperator*= (const Number &rhs)
 Multiplies the number by another number and assigns the result to the current number.
 
Numberoperator/= (const Number &rhs)
 Divides the number by another number and assigns the result to the current number.
 
Numberoperator%= (const Number &rhs)
 Calculates the remainder of two numbers and assigns the result to the current number.
 
Numberoperator^= (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.
 

Detailed Description

Represents a number with arbitrary precision. It basically stores the value as a string.

Constructor & Destructor Documentation

◆ Number() [1/2]

steppable::Number::Number ( )

The default constructor. Initializes the number with a value of 0.

Here is the caller graph for this function:

◆ Number() [2/2]

steppable::Number::Number ( std::string value = "0",
size_t prec = 0,
RoundingMode mode = USE_CURRENT_PREC )

Initializes a number with a specified value.

Note
By default, the value is 0.

Member Function Documentation

◆ operator!=()

bool steppable::Number::operator!= ( const Number & rhs) const

Compares two numbers for inequality.

Parameters
rhsThe number to compare.
Returns
True if the numbers are not equal, false otherwise.
Here is the call graph for this function:

◆ operator%()

Number steppable::Number::operator% ( const Number & rhs) const

Calculates the remainder of two numbers. (Modulus)

Parameters
rhsThe number to divide.
Returns
The remainder of the two numbers.
Here is the call graph for this function:

◆ operator%=()

Number & steppable::Number::operator%= ( const Number & rhs)

Calculates the remainder of two numbers and assigns the result to the current number.

Parameters
rhsThe number to divide.
Returns
The remainder of the two numbers.
Here is the call graph for this function:

◆ operator*()

Number steppable::Number::operator* ( const Number & rhs) const

Multiplies two numbers.

Parameters
rhsThe number to multiply.
Returns
The product of the two numbers.
Here is the call graph for this function:

◆ operator*=()

Number & steppable::Number::operator*= ( const Number & rhs)

Multiplies the number by another number and assigns the result to the current number.

Parameters
rhsThe number to multiply.
Returns
The product of the two numbers.
Here is the call graph for this function:

◆ operator+()

Number steppable::Number::operator+ ( const Number & rhs) const

Adds two numbers together.

Parameters
rhsThe number to add.
Returns
The sum of the two numbers.
Here is the call graph for this function:

◆ operator++()

Number steppable::Number::operator++ ( )

Increments the number by one.

Returns
The number after incrementing.
Here is the call graph for this function:

◆ operator+=()

Number & steppable::Number::operator+= ( const Number & rhs)

Adds the number to another number and assigns the result to the current number.

Parameters
rhsThe number to add.
Returns
The sum of the two numbers.
Here is the call graph for this function:

◆ operator-()

Number steppable::Number::operator- ( const Number & rhs) const

Subtracts two numbers.

Parameters
rhsThe number to subtract.
Returns
The difference of the two numbers.
Here is the call graph for this function:

◆ operator--()

Number steppable::Number::operator-- ( )

Decrements the number by one.

Returns
The number after decrementing.
Here is the call graph for this function:

◆ operator-=()

Number & steppable::Number::operator-= ( const Number & rhs)

Subtracts the number from another number and assigns the result to the current number.

Parameters
rhsThe number to subtract.
Returns
The difference of the two numbers.
Here is the call graph for this function:

◆ operator/()

Number steppable::Number::operator/ ( const Number & rhs) const

Divides two numbers.

Parameters
rhsThe number to divide.
Returns
The quotient of the two numbers.
Here is the call graph for this function:

◆ operator/=()

Number & steppable::Number::operator/= ( const Number & rhs)

Divides the number by another number and assigns the result to the current number.

Parameters
rhsThe number to divide.
Returns
The quotient of the two numbers.
Here is the call graph for this function:

◆ operator<()

bool steppable::Number::operator< ( const Number & rhs) const

Compares two numbers for less than.

Parameters
rhsThe number to compare.
Returns
True if the current number is less than the other number, false otherwise.
Here is the call graph for this function:

◆ operator<=()

bool steppable::Number::operator<= ( const Number & rhs) const

Compares two numbers for less than or equal to.

Parameters
rhsThe number to compare.
Returns
True if the current number is less than or equal to the other number, false otherwise.
Here is the call graph for this function:

◆ operator==()

bool steppable::Number::operator== ( const Number & rhs) const

Compares two numbers for equality.

Parameters
rhsThe number to compare.
Returns
True if the numbers are equal, false otherwise.
Here is the call graph for this function:

◆ operator>()

bool steppable::Number::operator> ( const Number & rhs) const

Compares two numbers for greater than.

Parameters
rhsThe number to compare.
Returns
True if the current number is greater than the other number, false otherwise.
Here is the call graph for this function:

◆ operator>=()

bool steppable::Number::operator>= ( const Number & rhs) const

Compares two numbers for greater than or equal to.

Parameters
rhsThe number to compare.
Returns
True if the current number is greater than or equal to the other number, false otherwise.
Here is the call graph for this function:

◆ operator^()

Number steppable::Number::operator^ ( const Number & rhs) const

Raises the number to a power.

Parameters
rhsThe power to raise the number to.
Returns
The result of the power operation.
Here is the call graph for this function:

◆ operator^=()

Number & steppable::Number::operator^= ( const Number & rhs)

Raises the number to a power and assigns the result to the current number.

Parameters
rhsThe power to raise the number to.
Returns
The result of the power operation.
Here is the call graph for this function:

◆ present()

std::string steppable::Number::present ( ) const
nodiscard

Presents the number in a human-readable format.

Returns
The number as a string.
Here is the caller graph for this function:

Member Data Documentation

◆ mode

RoundingMode steppable::Number::mode = USE_CURRENT_PREC
private

The rounding mode of the number.

◆ prec

size_t steppable::Number::prec
private

The precision of the number.

◆ value

std::string steppable::Number::value
private

The value of the number.


The documentation for this class was generated from the following files:
Untitled