37void throwCannotQuantizeOrConvert();
50 template <
class MantissaType>
51 typename std::enable_if<std::numeric_limits<MantissaType>::is_signed,
bool>::type
54 return static_cast<Decimal::Mantissa>((std::numeric_limits<MantissaType>::min)()) <= value &&
55 value <=
static_cast<Decimal::Mantissa>((std::numeric_limits<MantissaType>::max)());
58 template <
class MantissaType>
59 typename std::enable_if<!std::numeric_limits<MantissaType>::is_signed && (
sizeof(MantissaType) <
sizeof(
Decimal::Mantissa)),
bool>::type
63 value <= static_cast<Decimal::Mantissa>((std::numeric_limits<MantissaType>::max)());
66 template <
class MantissaType>
67 typename std::enable_if<!std::numeric_limits<MantissaType>::is_signed && (
sizeof(MantissaType) >=
sizeof(
Decimal::Mantissa)),
bool>::type
73 template <
class ExponentType>
74 typename std::enable_if<std::numeric_limits<ExponentType>::is_signed && (
sizeof(ExponentType) <
sizeof(
Decimal::Exponent)),
bool>::type
77 return static_cast<Decimal::Exponent>((std::numeric_limits<ExponentType>::min)()) <= value &&
78 value <=
static_cast<Decimal::Exponent>((std::numeric_limits<ExponentType>::max)());
81 template <
class ExponentType>
82 typename std::enable_if<std::numeric_limits<ExponentType>::is_signed && (
sizeof(ExponentType) >=
sizeof(
Decimal::Exponent)),
bool>::type
88 template <
class ExponentType>
89 typename std::enable_if<!std::numeric_limits<ExponentType>::is_signed && (
sizeof(ExponentType) <
sizeof(
Decimal::Exponent)),
bool>::type
93 value <= static_cast<Decimal::Exponent>((std::numeric_limits<ExponentType>::max)());
96 template <
class ExponentType>
97 typename std::enable_if<!std::numeric_limits<ExponentType>::is_signed && (
sizeof(ExponentType) >=
sizeof(
Decimal::Exponent)),
bool>::type
105inline constexpr bool isNull(
const Decimal&)
noexcept
131template <
class MantissaType>
134 const auto res =
quantize(operand, exponent).mantissa();
137 throwCannotQuantizeOrConvert();
139 return static_cast<MantissaType
>(res);
142template <
class MantissaType,
class ExponentType>
148template <
class MantissaType,
class ExponentType>
153 throwCannotQuantizeOrConvert();
156 static_cast<MantissaType
>(number.
mantissa()),
157 static_cast<ExponentType
>(number.
exponent()));
165template <
class DecimalT>
177bool decimalEqual(
const Decimal& left,
const Decimal& right)
noexcept;
180inline bool operator==(
const Decimal& left,
const Decimal& right)
noexcept
182 return ((left.exponent() == right.exponent()) ? (left.mantissa() == right.mantissa()) : decimalEqual(left, right));
186inline bool operator!=(
const Decimal& left,
const Decimal& right)
188 return ((left.exponent() == right.exponent()) ? (left.mantissa() != right.mantissa()) : !decimalEqual(left, right));
194bool decimalLess(
const Decimal& left,
const Decimal& right)
noexcept;
197inline bool operator<(
const Decimal& left,
const Decimal& right)
noexcept
199 return ((left.exponent() == right.exponent()) ? (left.mantissa() < right.mantissa()) : decimalLess(left, right));
203inline bool operator<=(
const Decimal& left,
const Decimal& right)
205 return !(right < left);
211 return (right < left);
217 return (right <= left);
222void decimalToStr(std::string&, Int64, Int32);
226size_t toStr(
const Decimal&, Char* buf,
size_t size);
237 return fromStr(value, str.c_str(), str.size());
241inline void toStr(std::string& str,
const Decimal& number)
243 decimalToStr(str, number.mantissa(), number.exponent());
247template <
class Mantissa,
class Exponent>
260template <
class Mantissa,
class Exponent>
273template <
class Mantissa,
class Exponent>
284template <
class Mantissa,
class Exponent>
295template <
class Decimal1,
class Decimal2>
296void checkAgsValid(
const Decimal1& arg1,
const Decimal2& arg2)
298 if (isNull(arg1) || isNull(arg2))
299 throw std::invalid_argument(
"Provided argument is Null.");
303template <
class Mantissa,
class Exponent>
307 if (isNull(left) && isNull(right))
314template <
class Mantissa,
class Exponent>
318 return !(left == right);
322template <
class Mantissa,
class Exponent>
326 checkAgsValid(left, right);
332template <
class Mantissa,
class Exponent>
336 checkAgsValid(left, right);
342template <
class Mantissa,
class Exponent>
346 checkAgsValid(left, right);
352template <
class Mantissa,
class Exponent>
356 checkAgsValid(left, right);
362template <
class Decimal1,
class Decimal2>
364 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
367 if (isNull(left) && isNull(right))
374template <
class Decimal1,
class Decimal2>
376 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
379 return !(left == right);
383template <
class Decimal1,
class Decimal2>
385 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
388 checkAgsValid(left, right);
394template <
class Decimal1,
class Decimal2>
396 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
399 checkAgsValid(left, right);
405template <
class Decimal1,
class Decimal2>
407 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
408 operator<(
const Decimal1& left,
const Decimal2& right)
410 checkAgsValid(left, right);
416template <
class Decimal1,
class Decimal2>
418 typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
419 operator<=(
const Decimal1& left,
const Decimal2& right)
421 checkAgsValid(left, right);
427template <
class Mantissa,
class Exponent>
434 return stream << str;
438template <
class Mantissa,
class Exponent>
445 return stream << str;
#define ONIXS_CMEMDH_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_MESSAGING_NAMESPACE_END
#define ONIXS_CMEMDH_COLDPATH
#define ONIXS_CMEMDH_EXPORTED
#define ONIXS_CMEMDH_NORETURN
#define ONIXS_CMEMDH_PURE
#define ONIXS_CMEMDH_NODISCARD
Mantissa mantissa() const noexcept
A real number with a floating exponent.
Exponent exponent() const noexcept
Mantissa mantissa() const noexcept
std::enable_if< std::numeric_limits< MantissaType >::is_signed, bool >::type isMantissaInRange(Decimal::Mantissa value) noexcept
std::enable_if< std::numeric_limits< ExponentType >::is_signed &&(sizeof(ExponentType)< sizeof(Decimal::Exponent)), bool >::type isExponentInRange(Decimal::Exponent value) noexcept
bool operator>=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Int32 DecimalExponent
Aliases exponent component type for the decimal type.
bool operator<=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Int64 DecimalMantissa
Aliases mantissa component type for the decimal type.
MantissaType quantizedMantissa(const Decimal &operand, Int32 exponent)
bool fromStr(Int8 &, const Char *, size_t)
bool operator!=(const TimeSpan &left, const TimeSpan &right) noexcept
Compares Timespans.
char Char
Character type alias.
bool operator==(const TimeSpan &left, const TimeSpan &right) noexcept
Compares Timespans.
bool quantize(const Decimal &operand, Int32 exponent, Decimal &quantized)
bool operator<(const TimeSpan &left, const TimeSpan &right) noexcept
Compares Timespans.
FloatingPointDecimal< DecimalMantissa, DecimalExponent > Decimal
Universal decimal type.
void convert(FixedPointDecimal< MantissaType, ExponentType > &res, const Decimal &number)
bool operator>(const TimeSpan &left, const TimeSpan &right) noexcept
Compares Timespans.
void toStr(std::string &, Int8)
Serializes given integer into a string.
std::ostream & operator<<(std::ostream &os, const Timestamp &value)
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
bool operator==(const MemoryPoolAllocator< Object > &left, const MemoryPoolAllocator< OtherObject > &right)