124#include <string_view>
126#include "nfx/detail/datatypes/CompilerSupport.h"
128namespace nfx::datatypes
161 inline explicit constexpr
Int128(
int val ) noexcept;
167 inline explicit constexpr
Int128( std::int64_t val ) noexcept;
173 inline explicit constexpr
Int128( std::uint32_t val ) noexcept;
179 inline explicit constexpr
Int128( std::uint64_t val ) noexcept;
186 constexpr
Int128( std::uint64_t low, std::uint64_t high ) noexcept;
188#if NFX_DATATYPES_HAS_NATIVE_INT128
193 explicit constexpr Int128( NFX_DATATYPES_NATIVE_INT128 val )
noexcept;
201 inline explicit Int128( std::string_view str );
361 inline bool operator<( std::int64_t val )
const noexcept;
375 inline bool operator>( std::int64_t val )
const noexcept;
403 inline bool operator<( std::uint64_t val )
const noexcept;
417 inline bool operator>( std::uint64_t val )
const noexcept;
654 [[nodiscard]] std::uint64_t
toLow() const noexcept;
661 [[nodiscard]] std::uint64_t
toHigh() const noexcept;
663#if NFX_DATATYPES_HAS_NATIVE_INT128
678 NFX_DATATYPES_NATIVE_INT128 toNative() const noexcept;
759 [[nodiscard]] std::array<std::int32_t, 4>
toBits() const noexcept;
766#if NFX_DATATYPES_HAS_NATIVE_INT128
768 NFX_DATATYPES_NATIVE_INT128 m_value;
773 std::uint64_t lower64bits;
774 std::uint64_t upper64bits;
807 return value.
isqrt();
832#include "nfx/detail/datatypes/Int128.inl"
Int128 isqrt(const Int128 &value)
Calculate integer square root (free function).
Decimal sqrt(const Decimal &value)
Compute square root using Newton-Raphson method (free function).
Decimal abs(const Decimal &value) noexcept
Get absolute value of decimal (free function).
Cross-platform high-precision decimal type.
Cross-platform 128-bit signed integer type.
bool operator<=(int val) const noexcept
Less than or equal comparison with signed 32-bit integer.
bool operator<=(float val) const noexcept
Less than or equal comparison with single-precision floating-point.
bool operator>(double val) const noexcept
Greater than comparison with double-precision floating-point.
~Int128()=default
Destructor.
Int128 operator-(const Int128 &other) const noexcept
Subtraction operator.
bool operator!=(const Decimal &val) const noexcept
Inequality comparison with Decimal.
bool operator==(int val) const noexcept
Equality comparison with signed 32-bit integer.
Int128 & operator/=(const Int128 &other)
Division assignment operator.
bool operator>(std::int64_t val) const noexcept
Greater than comparison with signed 64-bit integer.
bool operator<(std::uint64_t val) const noexcept
Less than comparison with unsigned 64-bit integer.
Int128(double val)
Construct from double-precision floating-point value.
bool operator==(float val) const noexcept
Equality comparison with single-precision floating-point.
Int128 & operator*=(const Int128 &other) noexcept
Multiplication assignment operator.
bool operator>(const Decimal &val) const noexcept
Greater than comparison with Decimal.
Int128 abs() const noexcept
Get absolute value.
bool operator>=(int val) const noexcept
Greater than or equal comparison with signed 32-bit integer.
constexpr Int128 & operator=(const Int128 &other) noexcept=default
Copy assignment operator.
Int128 isqrt() const
Calculate integer square root (floor of exact square root).
Int128 & operator-=(const Int128 &other) noexcept
Subtraction assignment operator.
bool operator<(double val) const noexcept
Less than comparison with double-precision floating-point.
Int128(float val)
Construct from single-precision floating-point value.
std::strong_ordering operator<=>(const Int128 &other) const noexcept
Three-way comparison operator (C++20).
bool operator<=(std::int64_t val) const noexcept
Less than or equal comparison with signed 64-bit integer.
bool operator<(const Decimal &val) const noexcept
Less than comparison with Decimal.
constexpr Int128(const Int128 &other) noexcept=default
Copy constructor.
bool operator>=(const Decimal &val) const noexcept
Greater than or equal comparison with Decimal.
bool operator!=(std::uint64_t val) const noexcept
Inequality comparison with unsigned 64-bit integer.
Int128(std::string_view str)
Construct from string (exact parsing).
Int128(const Decimal &decimal)
Construct from Decimal value.
std::array< std::int32_t, 4 > toBits() const noexcept
Get internal 32-bit representation.
static bool fromString(std::string_view str, Int128 &result) noexcept
Try to parse 128-bit integer from string without throwing.
bool operator>=(double val) const noexcept
Greater than or equal comparison with double-precision floating-point.
bool operator>(std::uint64_t val) const noexcept
Greater than comparison with unsigned 64-bit integer.
Int128 operator/(const Int128 &other) const
Division operator.
Int128 operator-() const noexcept
Unary minus operator.
bool operator!=(int val) const noexcept
Inequality comparison with signed 32-bit integer.
bool operator>=(std::int64_t val) const noexcept
Greater than or equal comparison with signed 64-bit integer.
bool operator>(float val) const noexcept
Greater than comparison with single-precision floating-point.
Int128 operator+(const Int128 &other) const noexcept
Addition operator.
constexpr Int128() noexcept
Default constructor.
bool operator==(std::uint64_t val) const noexcept
Equality comparison with unsigned 64-bit integer.
Int128 & operator%=(const Int128 &other)
Modulo assignment operator.
std::uint64_t toLow() const noexcept
Get lower 64 bits.
bool operator==(std::int64_t val) const noexcept
Equality comparison with signed 64-bit integer.
bool operator==(double val) const noexcept
Equality comparison with double-precision floating-point.
constexpr Int128 & operator=(Int128 &&other) noexcept=default
Move assignment operator.
bool operator!=(float val) const noexcept
Inequality comparison with single-precision floating-point.
Int128 & operator+=(const Int128 &other) noexcept
Addition assignment operator.
bool operator==(const Decimal &val) const noexcept
Equality comparison with Decimal.
bool operator!=(std::int64_t val) const noexcept
Inequality comparison with signed 64-bit integer.
bool operator>=(float val) const noexcept
Greater than or equal comparison with single-precision floating-point.
bool operator>=(std::uint64_t val) const noexcept
Greater than or equal comparison with unsigned 64-bit integer.
bool operator==(const Int128 &other) const noexcept
Equality operator.
bool operator<(std::int64_t val) const noexcept
Less than comparison with signed 64-bit integer.
bool operator<(int val) const noexcept
Less than comparison with signed 32-bit integer.
bool operator<=(std::uint64_t val) const noexcept
Less than or equal comparison with unsigned 64-bit integer.
std::string toString() const
Convert to string with exact precision.
bool operator<=(double val) const noexcept
Less than or equal comparison with double-precision floating-point.
Int128 operator%(const Int128 &other) const
Modulo operator.
bool operator>(int val) const noexcept
Greater than comparison with signed 32-bit integer.
bool operator<=(const Decimal &val) const noexcept
Less than or equal comparison with Decimal.
Int128 operator*(const Int128 &other) const noexcept
Multiplication operator.
std::uint64_t toHigh() const noexcept
Get upper 64 bits.
constexpr Int128(Int128 &&other) noexcept=default
Move constructor.
bool operator<(float val) const noexcept
Less than comparison with single-precision floating-point.
bool operator!=(double val) const noexcept
Inequality comparison with double-precision floating-point.