sparrow 0.9.0
|
#include <decimal.hpp>
Public Types | |
using | integer_type = T |
Public Member Functions | |
constexpr | decimal () |
Default constructor for non-placeholder integer types. | |
constexpr | decimal () |
Default constructor for placeholder integer types. | |
constexpr | decimal (T value, int scale) |
Constructor from value and scale. | |
constexpr bool | operator== (const decimal &other) const |
Equality comparison operator. | |
constexpr | operator float () const |
Conversion to float. | |
constexpr | operator double () const |
Conversion to double. | |
constexpr | operator long double () const |
Conversion to long double. | |
operator std::string () const | |
Conversion to string representation. | |
constexpr T | storage () const |
Gets the raw storage value. | |
constexpr int | scale () const |
Gets the decimal scale. | |
Definition at line 61 of file decimal.hpp.
using sparrow::decimal< T >::integer_type = T |
Definition at line 65 of file decimal.hpp.
|
constexpr |
Default constructor for non-placeholder integer types.
Creates a decimal representing zero with scale 0.
Definition at line 259 of file decimal.hpp.
|
constexpr |
Default constructor for placeholder integer types.
Creates a decimal with default-initialized storage and scale. Used for placeholder types that don't have well-defined zero values.
|
constexpr |
Constructor from value and scale.
Creates a decimal representing the value: value * 10^(-scale).
value | The integer coefficient of the decimal number |
scale | The decimal scale (number of digits after decimal point) |
Definition at line 275 of file decimal.hpp.
|
explicitconstexpr |
Conversion to double.
Converts the decimal to a double-precision floating-point value. Provides better precision than float conversion but may still lose precision for very large or high-precision decimals.
Definition at line 295 of file decimal.hpp.
|
explicitconstexpr |
Conversion to float.
Converts the decimal to a floating-point value by computing storage() / 10^scale(). May lose precision for large values or high precision decimals.
Definition at line 288 of file decimal.hpp.
|
explicitconstexpr |
Conversion to long double.
Converts the decimal to a long double floating-point value. Provides the highest precision among floating-point conversions but may still lose precision for extremely large or high-precision decimals.
Definition at line 302 of file decimal.hpp.
|
explicitnodiscard |
Conversion to string representation.
Converts the decimal to its human-readable string representation with proper decimal point placement and sign handling.
Definition at line 309 of file decimal.hpp.
|
constexpr |
Equality comparison operator.
Two decimals are equal if they have the same storage value and scale. Note: This does not perform mathematical equality (e.g., 1.0 vs 10.00 with different scales would not be considered equal).
other | Decimal to compare with |
Definition at line 282 of file decimal.hpp.
|
nodiscardconstexpr |
Gets the decimal scale.
Definition at line 362 of file decimal.hpp.
|
nodiscardconstexpr |
Gets the raw storage value.
Definition at line 356 of file decimal.hpp.