Hyper API for C++ 0.0.20746
Hyper client library for C++ applications
|
A fixed-point numeric data value with scale
fraction digits and precision
digits overall.
More...
#include <Numeric.hpp>
Public Types | |
using | data_t = typename std::conditional< precision<=18, int64_t, hyper_data128_t >::type |
Public Member Functions | |
Numeric () noexcept | |
Default constructor. | |
Numeric (short value) | |
Creates a numeric value from an integer. | |
Numeric (unsigned short value) | |
Creates a numeric value from an integer. | |
Numeric (int value) | |
Creates a numeric value from an integer. | |
Numeric (unsigned value) | |
Creates a numeric value from an integer. | |
Numeric (long value) | |
Creates a numeric value from an integer. | |
Numeric (unsigned long value) | |
Creates a numeric value from an integer. | |
Numeric (long long value) | |
Creates a numeric value from an integer. | |
Numeric (unsigned long long value) | |
Creates a numeric value from an integer. | |
Numeric (float value) | |
Creates a numeric value from a float; may lose accuracy. | |
Numeric (double value) | |
Creates a numeric value from a double; may lose accuracy. | |
Numeric (long double value) | |
Creates a numeric value from a double; may lose accuracy. | |
template<unsigned otherPrecision, unsigned otherScale> | |
Numeric (hyperapi::Numeric< otherPrecision, otherScale > other) | |
Creates a numeric value from another numeric value with different precision and scale. | |
Numeric (hyperapi::string_view value) | |
Creates a numeric value from a string representation. | |
std::string | stringValue () const |
Gets an exact string representation, which is round-trip compatible with the constructor, i.e., n == Numeric(n.stringValue()) | |
int64_t | intValue () const |
Gets an integer representation of this value; if the value has fraction digits, these will be truncated. | |
operator int64_t () const | |
Explicit conversion to int64_t. | |
float | floatValue () const noexcept |
Gets a float representation of this value; may lose accuracy. | |
operator float () const noexcept | |
Explicit conversion to float. | |
double | doubleValue () const noexcept |
Gets a double representation of this value; may lose accuracy. | |
operator double () const noexcept | |
Explicit conversion to double. | |
std::string | toString () const |
Gets a string representation for debugging. | |
Static Public Attributes | |
static constexpr unsigned | precision = precision_value |
static constexpr unsigned | scale = scale_value |
A fixed-point numeric data value with scale
fraction digits and precision
digits overall.
Definition at line 47 of file Numeric.hpp.
using hyperapi::Numeric< precision_value, scale_value >::data_t = typename std::conditional<precision <= 18, int64_t, hyper_data128_t>::type |
Definition at line 54 of file Numeric.hpp.
|
inlinenoexcept |
Default constructor.
Definition at line 59 of file Numeric.hpp.
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | short | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | unsigned short | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | int | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | unsigned | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | long | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | unsigned long | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | long long | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | unsigned long long | value | ) |
Creates a numeric value from an integer.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | float | value | ) |
Creates a numeric value from a float; may lose accuracy.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | double | value | ) |
Creates a numeric value from a double; may lose accuracy.
HyperException | if the value cannot be represented with the specified precision and scale. |
hyperapi::Numeric< precision_value, scale_value >::Numeric | ( | long double | value | ) |
Creates a numeric value from a double; may lose accuracy.
HyperException | if the value cannot be represented with the specified precision and scale. |
|
explicit |
Creates a numeric value from another numeric value with different precision and scale.
HyperException | if the value cannot be represented with the specified precision and scale. |
|
explicit |
Creates a numeric value from a string representation.
HyperException | if value is not a valid numeric representation or overflows. |
int64_t hyperapi::Numeric< precision_value, scale_value >::intValue | ( | ) | const |
Gets an integer representation of this value; if the value has fraction digits, these will be truncated.
HyperException | if the value cannot be represented in 64-bit. |
|
inlinenoexcept |
Explicit conversion to double.
Definition at line 163 of file Numeric.hpp.
|
inlinenoexcept |
Explicit conversion to float.
Definition at line 154 of file Numeric.hpp.
|
inline |
Explicit conversion to int64_t.
HyperException | if the value cannot be represented in 64-bit. |
Definition at line 145 of file Numeric.hpp.
std::string hyperapi::Numeric< precision_value, scale_value >::toString | ( | ) | const |
Gets a string representation for debugging.
Currently, the result is equivalent to calling stringValue(), but this is not guaranteed; it might change in future versions.
|
staticconstexpr |
Definition at line 49 of file Numeric.hpp.
|
staticconstexpr |
Definition at line 50 of file Numeric.hpp.