90 template<__
internals::utils::StringLiteral fnName>
107 output::warning(std::string(fnName.value),
"Invalid precision specified"s);
129 template<concepts::Numeric ValueT>
135 void set(std::string newVal) {
value = std::move(newVal); }
308 [[nodiscard]] std::string
present()
const;
317 inline Number operator""_n(
long double value) {
return Number(value); }
319 inline Number operator""_n(
unsigned long long value) {
return Number(value); }
Represents a number with arbitrary precision. It basically stores the value as a string.
Definition number.hpp:80
bool operator>=(const Number &rhs) const
Compares two numbers for greater than or equal to.
Definition number.cpp:142
Number operator*(const Number &rhs) const
Multiplies two numbers.
Definition number.cpp:63
Number & operator*=(const Number &rhs)
Multiplies the number by another number and assigns the result to the current number.
Definition number.cpp:106
bool operator<=(const Number &rhs) const
Compares two numbers for less than or equal to.
Definition number.cpp:140
Number & operator%=(const Number &rhs)
Calculates the remainder of two numbers and assigns the result to the current number.
Definition number.cpp:120
size_t prec
The precision of the number.
Definition number.hpp:85
bool operator<(const Number &rhs) const
Compares two numbers for less than.
Definition number.cpp:136
bool operator!=(const Number &rhs) const
Compares two numbers for inequality.
Definition number.cpp:134
bool operator>(const Number &rhs) const
Compares two numbers for greater than.
Definition number.cpp:138
Number operator--()
Decrements the number by one.
Definition number.cpp:160
Number & operator^=(const Number &rhs)
Raises the number to a power and assigns the result to the current number.
Definition number.cpp:126
Number & operator-=(const Number &rhs)
Subtracts the number from another number and assigns the result to the current number.
Definition number.cpp:99
Number mod(const Number &rhs) const
Takes a modulus operation.
Definition number.cpp:82
Number operator++()
Increments the number by one.
Definition number.cpp:154
Number operator%(const Number &rhs) const
Calculates the remainder of two numbers. (Modulus)
Definition number.cpp:77
Number & operator/=(const Number &rhs)
Divides the number by another number and assigns the result to the current number.
Definition number.cpp:113
std::string value
The value of the number.
Definition number.hpp:82
Number(ValueT value, size_t prec=10, RoundingMode mode=RoundingMode::USE_CURRENT_PREC)
Initializes a number with a C/C++ long double value.
Definition number.hpp:130
RoundingMode mode
The rounding mode of the number.
Definition number.hpp:88
Number()
The default constructor. Initializes the number with a value of 0.
Definition number.cpp:50
Number operator+() const
Unary plus operator.
Definition number.cpp:152
std::string present() const
Presents the number in a human-readable format.
Definition number.cpp:166
size_t determinePrec(const Number &rhs) const
Definition number.hpp:91
Number & operator+=(const Number &rhs)
Adds the number to another number and assigns the result to the current number.
Definition number.cpp:93
bool operator==(const Number &rhs) const
Compares two numbers for equality.
Definition number.cpp:132
void set(std::string newVal)
Definition number.hpp:135
void setPrec(size_t newPrec, RoundingMode mode=RoundingMode::USE_CURRENT_PREC)
Definition number.hpp:137
Number operator-() const
Unary minus operator.
Definition number.cpp:144
Number operator/(const Number &rhs) const
Divides two numbers.
Definition number.cpp:70
Number operator^(const Number &rhs)
Raises the number to a power.
Definition number.cpp:87
Literal suffixes for literals to be converted to Steppable objects.
void warning(const std::basic_string< T > &name, const std::basic_string< T > &msg, const std::vector< std::string > &args={})
Prints a warning message.
Definition output.hpp:107
The public namespace for the Steppable library.
Definition argParse.cpp:40
Rounding
Definition number.hpp:69
@ ROUND_DOWN
Rounds the number down.
Definition number.hpp:70
@ ROUND_UP
Rounds the number up.
Definition number.hpp:71
@ ROUND_OFF
Rounds the number off.
Definition number.hpp:72
RoundingMode
Specifies how Steppable should round the number in operations.
Definition number.hpp:51
@ DISCARD_ALL_DECIMALS
Do not append any decimal places.
Definition number.hpp:65
@ USE_MINIMUM_PREC
Use the lower precision whenever possible.
Definition number.hpp:56
@ USE_OTHER_PREC
Use the other number's precision.
Definition number.hpp:62
@ USE_MAXIMUM_PREC
Use the higher precision whenever possible.
Definition number.hpp:53
@ USE_CURRENT_PREC
Use the current precision.
Definition number.hpp:59