69template <
class MantissaType>
78 if(
static_cast<MantissaType
>(
79 (std::numeric_limits<MantissaType>::max)()) >= res)
81 return static_cast<MantissaType
>(res);
110 if(
static_cast<MantissaType
>(
111 (std::numeric_limits<MantissaType>::max)()) < number.
mantissa())
118 static_cast<MantissaType
>(number.
mantissa()),
133typename std::enable_if<details::IsDecimal<DecimalT>::value, DecimalT>::type
150 return ((left.exponent() == right.exponent()) ? (left.mantissa() == right.mantissa()) :
decimalEqual(left, right));
167inline bool operator <(
170 return ((left.exponent() == right.exponent()) ? (left.mantissa() < right.mantissa()) :
decimalLess(left, right));
177 return !(right < left);
188 return (right < left);
199 return (right <= left);
232 const std::string& str)
noexcept
267 <Mantissa, Exponent>& number)
287 std::ostream& stream,
290 <Mantissa, Exponent>& value)
296 return stream << str;
311 <Mantissa, Exponent>& number)
364std::ostream& operator << (std::ostream& stream,
const Decimal& value)
370 return stream << str;
382 std::ostream& stream,
385 <Mantissa, Exponent>& value)
391 return stream << str;
401 const Decimal1& arg1,
const Decimal2& arg2)
404 throw std::invalid_argument(
"Provided argument is Null.");
419 <Mantissa, Exponent>& left,
422 <Mantissa, Exponent>& right)
427 return left.mantissa() == right.mantissa();
442 <Mantissa, Exponent>& left,
445 <Mantissa, Exponent>& right)
447 return !(left == right);
462 <Mantissa, Exponent>& left,
465 <Mantissa, Exponent>& right)
467 checkAgsValid(left, right);
469 return left.mantissa() < right.mantissa();
484 <Mantissa, Exponent>& left,
487 <Mantissa, Exponent>& right)
489 checkAgsValid(left, right);
491 return left.mantissa() > right.mantissa();
506 <Mantissa, Exponent>& left,
509 <Mantissa, Exponent>& right)
511 checkAgsValid(left, right);
513 return left.mantissa() <= right.mantissa();
528 <Mantissa, Exponent>& left,
531 <Mantissa, Exponent>& right)
533 checkAgsValid(left, right);
535 return left.mantissa() >= right.mantissa();
546typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
548 const Decimal1& left,
const Decimal2& right)
564typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
566 const Decimal1& left,
const Decimal2& right)
568 return !(left == right);
579typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
581 const Decimal1& left,
const Decimal2& right)
583 checkAgsValid(left, right);
596typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
598 const Decimal1& left,
const Decimal2& right)
600 checkAgsValid(left, right);
613typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
615 const Decimal1& left,
const Decimal2& right)
617 checkAgsValid(left, right);
630typename std::enable_if<details::AreBothDecimals<Decimal1, Decimal2>::value,
bool>::type
632 const Decimal1& left,
const Decimal2& right)
634 checkAgsValid(left, right);
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
#define ONIXS_ICEBOE_EXPORTED
#define ONIXS_ICEBOE_PURE
#define ONIXS_ICEBOE_NODISCARD
A real number with a floating exponent.
Exponent exponent() const noexcept
Mantissa mantissa() const noexcept
bool operator>=(const Decimal &left, const Decimal &right)
std::ostream & operator<<(std::ostream &stream, const FloatingPointDecimal< Mantissa, Exponent > &value)
Serializes into a stream.
FloatingPointDecimal< Int64, Int32 > Decimal
Universal decimal type.
MantissaType quantizedMantissa(const Decimal &operand, Int32 exponent)
Quantize so its exponent is the same as that of provided value.
constexpr std::enable_if<!details::HasMemberTraits< Value >::value, size_t >::type size() noexcept
bool decimalLess(const Decimal &left, const Decimal &right) noexcept
bool operator>(const Decimal &left, const Decimal &right)
bool operator!=(const Decimal &left, const Decimal &right)
bool decimalEqual(const Decimal &left, const Decimal &right) noexcept
char Char
Character type alias.
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &)
Serializes a fixed-point decimal into a string.
bool quantize(const Decimal &operand, Int32 exponent, Decimal &quantized)
Quantize so its exponent is the same as that of provided value.
void decimalToStr(std::string &, Int64, Int32)
bool operator<=(const Decimal &left, const Decimal &right)
bool operator<(const Decimal &left, const Decimal &right) noexcept
void throwCannotQuantizeOrConvert()
bool fromStr(Decimal &, const Char *, size_t) noexcept
Deserializes a decimal number from the given text presentation.
bool operator==(const Decimal &left, const Decimal &right) noexcept
constexpr bool isNull(const Decimal &) noexcept
ONIXS_ICEBOE_FORCEINLINE auto convert(typename ArgType< Callable >::type value) noexcept(noexcept(Callable::Nothrow)) -> decltype(std::declval< Callable >()(std::declval< typename ArgType< Callable >::type >()))