36 template <
class MantissaType,
class ExponentType>
55 Size =
sizeof(Mantissa)
84 MantissaType mantissa_;
88 template <
class Mantissa,
class Exponent>
95 template <
class Mantissa,
class Exponent>
102 template <
class Mantissa,
class Exponent>
105 return (left.mantissa() < right.mantissa());
109 template <
class Mantissa,
class Exponent>
116 template <
class Mantissa,
class Exponent>
119 return (left.mantissa() <= right.mantissa());
123 template <
class Mantissa,
class Exponent>
154 : mantissa_(mantissa)
155 , exponent_(exponent)
161 : mantissa_(other.mantissa_)
162 , exponent_(other.exponent_)
168 template <
class AMantissa,
class AExponent>
170 : mantissa_(other.mantissa())
171 , exponent_(other.exponent())
190 mantissa_ = other.mantissa_;
191 exponent_ = other.exponent_;
198 template <
class AMantissa,
class AExponent>
229 template <
class Mantissa,
class Exponent>
232 return (left ==
Decimal(right));
236 template <
class Mantissa,
class Exponent>
239 return (
Decimal(left) == right);
243 template <
class Mantissa,
class Exponent>
246 return (left !=
Decimal(right));
250 template <
class Mantissa,
class Exponent>
253 return (
Decimal(left) != right);
269 return (right < left);
275 return !(right < left);
281 return !(right > left);
285 template <
class Mantissa,
class Exponent>
286 inline bool operator<(const Decimal& left, const FixedPointDecimal<Mantissa, Exponent>& right)
288 return (left <
Decimal(right));
292 template <
class Mantissa,
class Exponent>
293 inline bool operator<(const FixedPointDecimal<Mantissa, Exponent>& left,
const Decimal& right)
295 return (
Decimal(left) < right);
299 template <
class Mantissa,
class Exponent>
302 return (left >
Decimal(right));
306 template <
class Mantissa,
class Exponent>
309 return (
Decimal(left) > right);
339 template <
class Mantissa,
class Exponent>
346 template <
class Mantissa,
class Exponent>
Int64 DecimalMantissa
Aliases mantissa component type for the decimal type.
bool operator==(const FixedPointDecimal< Mantissa, Exponent > &left, const Decimal &right)
Checks two decimals for equality.
DecimalMantissa Mantissa
Aliases mantissa component type.
Int32 DecimalExponent
Aliases exponent component type for the decimal type.
DecimalExponent Exponent
Aliases exponent component type.
Decimal()
Default (zero) initialization.
Decimal(const Decimal &other)
Initializes instance as copy of the other one.
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &number)
Serializes fixed-point decimal into a string.
Decimal(Mantissa mantissa, Exponent exponent)
Explicitly initializes instance from its mantissa value.
bool operator>(const FixedPointDecimal< Mantissa, Exponent > &left, const Decimal &right)
Compares two decimals.
void decimalToStr(std::string &, Int64, Int32)
Serializes decimal presented by mantissa and exponent into a string.
Represents real number with constant exponent.
#define ONIXS_CMEMDH_LTWT
Decimal(const FixedPointDecimal< AMantissa, AExponent > &other)
Initializes instance from the fixed point decimal.
Mantissa mantissa() const
Returns mantissa of given decimal.
Decimal & operator=(const FixedPointDecimal< AMantissa, AExponent > &other)
Re-initializes instance as a copy of the fixed point value.
char Char
Character type alias.
MantissaType Mantissa
Aliases mantissa component type.
bool decimalEqual(const Decimal &left, const Decimal &right)
Checks two decimals for equality.
FixedPointDecimal(Mantissa mantissa)
Explicitly initializes instance from its mantissa value.
bool decimalLess(const Decimal &left, const Decimal &right)
Compares two decimals.
A real number with floating exponent.
bool operator>=(const Decimal &left, const Decimal &right)
Compares two decimals.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Mantissa mantissa() const
Returns mantissa of given decimal.
bool fromStr(Decimal &, const Char *, size_t)
Deserializes a decimal number from the given text presentation.
Exponent exponent() const
Returns exponent of given decimal.
Exponent exponent() const
Returns exponent of given decimal.
#define ONIXS_CMEMDH_EXPORTED
Decimal & operator=(const Decimal &other)
Re-initializes instance as copy of the other one.
bool operator<(const FixedPointDecimal< Mantissa, Exponent > &left, const Decimal &right)
Compares two decimals.
ExponentType Exponent
Aliases exponent component type.
bool operator<=(const Decimal &left, const Decimal &right)
Compares two decimals.
bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const Decimal &right)
Checks two decimals for inequality.
FixedPointDecimal()
Default (zero) initialization.
#define ONIXS_CMEMDH_NAMESPACE_END