|
nfx-datatypes 0.1.1
Cross-platform C++ library with high-precision Int128 and Decimal datatypes
|
Cross-platform 128-bit signed integer type. More...
#include <nfx/datatypes/Int128.h>
Public Member Functions | |
| constexpr | Int128 () noexcept |
| Default constructor. | |
| constexpr | Int128 (int val) noexcept |
| Construct from signed 32-bit integer. | |
| constexpr | Int128 (std::int64_t val) noexcept |
| Construct from signed 64-bit integer. | |
| constexpr | Int128 (std::uint32_t val) noexcept |
| Construct from unsigned 32-bit integer. | |
| constexpr | Int128 (std::uint64_t val) noexcept |
| Construct from unsigned 64-bit integer. | |
| constexpr | Int128 (std::uint64_t low, std::uint64_t high) noexcept |
| Construct from two 64-bit words. | |
| Int128 (std::string_view str) | |
| Construct from string (exact parsing). | |
| Int128 (float val) | |
| Construct from single-precision floating-point value. | |
| Int128 (double val) | |
| Construct from double-precision floating-point value. | |
| Int128 (const Decimal &decimal) | |
| Construct from Decimal value. | |
| constexpr | Int128 (const Int128 &other) noexcept=default |
| Copy constructor. | |
| constexpr | Int128 (Int128 &&other) noexcept=default |
| Move constructor. | |
| ~Int128 ()=default | |
| Destructor. | |
| constexpr Int128 & | operator= (const Int128 &other) noexcept=default |
| Copy assignment operator. | |
| constexpr Int128 & | operator= (Int128 &&other) noexcept=default |
| Move assignment operator. | |
| std::strong_ordering | operator<=> (const Int128 &other) const noexcept |
| Three-way comparison operator (C++20). | |
| bool | operator== (const Int128 &other) const noexcept |
| Equality operator. | |
| bool | operator== (int val) const noexcept |
| Equality comparison with signed 32-bit integer. | |
| bool | operator!= (int val) const noexcept |
| Inequality comparison with signed 32-bit integer. | |
| bool | operator< (int val) const noexcept |
| Less than comparison with signed 32-bit integer. | |
| bool | operator<= (int val) const noexcept |
| Less than or equal comparison with signed 32-bit integer. | |
| bool | operator> (int val) const noexcept |
| Greater than comparison with signed 32-bit integer. | |
| bool | operator>= (int val) const noexcept |
| Greater than or equal comparison with signed 32-bit integer. | |
| bool | operator== (std::int64_t val) const noexcept |
| Equality comparison with signed 64-bit integer. | |
| bool | operator!= (std::int64_t val) const noexcept |
| Inequality comparison with signed 64-bit integer. | |
| bool | operator< (std::int64_t val) const noexcept |
| Less than comparison with signed 64-bit integer. | |
| bool | operator<= (std::int64_t val) const noexcept |
| Less than or equal comparison with signed 64-bit integer. | |
| bool | operator> (std::int64_t val) const noexcept |
| Greater than comparison with signed 64-bit integer. | |
| bool | operator>= (std::int64_t val) const noexcept |
| Greater than or equal comparison with signed 64-bit integer. | |
| bool | operator== (std::uint64_t val) const noexcept |
| Equality comparison with unsigned 64-bit integer. | |
| bool | operator!= (std::uint64_t val) const noexcept |
| Inequality comparison with unsigned 64-bit integer. | |
| bool | operator< (std::uint64_t val) const noexcept |
| Less than comparison with unsigned 64-bit integer. | |
| bool | operator<= (std::uint64_t val) const noexcept |
| Less than or equal comparison with unsigned 64-bit integer. | |
| bool | operator> (std::uint64_t val) const noexcept |
| Greater than comparison with unsigned 64-bit integer. | |
| bool | operator>= (std::uint64_t val) const noexcept |
| Greater than or equal comparison with unsigned 64-bit integer. | |
| bool | operator== (float val) const noexcept |
| Equality comparison with single-precision floating-point. | |
| bool | operator!= (float val) const noexcept |
| Inequality comparison with single-precision floating-point. | |
| bool | operator< (float val) const noexcept |
| Less than comparison with single-precision floating-point. | |
| bool | operator<= (float val) const noexcept |
| Less than or equal comparison with single-precision floating-point. | |
| bool | operator> (float val) const noexcept |
| Greater than comparison with single-precision floating-point. | |
| bool | operator>= (float val) const noexcept |
| Greater than or equal comparison with single-precision floating-point. | |
| bool | operator== (double val) const noexcept |
| Equality comparison with double-precision floating-point. | |
| bool | operator!= (double val) const noexcept |
| Inequality comparison with double-precision floating-point. | |
| bool | operator< (double val) const noexcept |
| Less than comparison with double-precision floating-point. | |
| bool | operator<= (double val) const noexcept |
| Less than or equal comparison with double-precision floating-point. | |
| bool | operator> (double val) const noexcept |
| Greater than comparison with double-precision floating-point. | |
| bool | operator>= (double val) const noexcept |
| Greater than or equal comparison with double-precision floating-point. | |
| bool | operator== (const Decimal &val) const noexcept |
| Equality comparison with Decimal. | |
| bool | operator!= (const Decimal &val) const noexcept |
| Inequality comparison with Decimal. | |
| bool | operator< (const Decimal &val) const noexcept |
| Less than comparison with Decimal. | |
| bool | operator<= (const Decimal &val) const noexcept |
| Less than or equal comparison with Decimal. | |
| bool | operator> (const Decimal &val) const noexcept |
| Greater than comparison with Decimal. | |
| bool | operator>= (const Decimal &val) const noexcept |
| Greater than or equal comparison with Decimal. | |
| Int128 | operator+ (const Int128 &other) const noexcept |
| Addition operator. | |
| Int128 | operator- (const Int128 &other) const noexcept |
| Subtraction operator. | |
| Int128 | operator* (const Int128 &other) const noexcept |
| Multiplication operator. | |
| Int128 | operator/ (const Int128 &other) const |
| Division operator. | |
| Int128 & | operator+= (const Int128 &other) noexcept |
| Addition assignment operator. | |
| Int128 & | operator-= (const Int128 &other) noexcept |
| Subtraction assignment operator. | |
| Int128 & | operator*= (const Int128 &other) noexcept |
| Multiplication assignment operator. | |
| Int128 & | operator/= (const Int128 &other) |
| Division assignment operator. | |
| Int128 & | operator%= (const Int128 &other) |
| Modulo assignment operator. | |
| Int128 | operator% (const Int128 &other) const |
| Modulo operator. | |
| Int128 | operator- () const noexcept |
| Unary minus operator. | |
| std::uint64_t | toLow () const noexcept |
| Get lower 64 bits. | |
| std::uint64_t | toHigh () const noexcept |
| Get upper 64 bits. | |
| Int128 | abs () const noexcept |
| Get absolute value. | |
| Int128 | isqrt () const |
| Calculate integer square root (floor of exact square root). | |
| std::string | toString () const |
| Convert to string with exact precision. | |
| std::array< std::int32_t, 4 > | toBits () const noexcept |
| Get internal 32-bit representation. | |
Static Public Member Functions | |
| static bool | fromString (std::string_view str, Int128 &result) noexcept |
| Try to parse 128-bit integer from string without throwing. | |
| static std::optional< Int128 > | fromString (std::string_view str) noexcept |
| Parse 128-bit integer from string with optional return. | |
Cross-platform 128-bit signed integer type.
Implements portable 128-bit signed integer arithmetic with:
|
inlineexplicitconstexprnoexcept |
Construct from signed 32-bit integer.
| val | 32-bit signed value |

|
inlineexplicitconstexprnoexcept |
Construct from signed 64-bit integer.
| val | 64-bit signed value |

|
inlineexplicitconstexprnoexcept |
Construct from unsigned 32-bit integer.
| val | 32-bit unsigned value |

|
inlineexplicitconstexprnoexcept |
Construct from unsigned 64-bit integer.
| val | 64-bit unsigned value |

|
constexprnoexcept |
Construct from two 64-bit words.
| low | Lower 64 bits |
| high | Upper 64 bits |

|
inlineexplicit |
Construct from string (exact parsing).
| str | String representation (e.g., "123", "-456789") |
| std::invalid_argument | if string is not a valid integer |
|
explicit |
Construct from single-precision floating-point value.
| val | Float value to convert |
Follows C++ standard truncation behavior (like static_cast<int>(float)):
|
explicit |
Construct from double-precision floating-point value.
| val | Double value to convert |
Follows C++ standard truncation behavior (like static_cast<int>(double)):
|
explicit |
Construct from Decimal value.
| decimal | Decimal value to convert |
Follows C++ standard truncation behavior (like static_cast<int>(double)):
|
constexprdefaultnoexcept |
Copy constructor.
| other | The Int128 object to copy from |

|
constexprdefaultnoexcept |
Move constructor.
| other | The Int128 object to move from |

|
inlinenodiscardnoexcept |
Get absolute value.

|
staticnodiscardnoexcept |
Parse 128-bit integer from string with optional return.
| str | String representation of integer (e.g., "12345", "-9876543210") |
This is a convenience wrapper around the two-parameter fromString method. Supports the same input formats:

|
staticnodiscardnoexcept |
Try to parse 128-bit integer from string without throwing.
| str | String representation of integer (e.g., "12345", "-9876543210") |
| result | Output parameter to store parsed value on success |
Parses string representations of 128-bit signed integers with comprehensive format support. Supported input formats:


|
nodiscard |
Calculate integer square root (floor of exact square root).
| std::domain_error | if this is negative |


|
inlinenoexcept |
Inequality comparison with Decimal.
| val | Right operand |
|
inlinenoexcept |
Inequality comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Inequality comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Inequality comparison with signed 32-bit integer.
| val | Right operand |
|
noexcept |
Inequality comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Inequality comparison with unsigned 64-bit integer.
| val | Right operand |
Modulo operator.
| other | Divisor |
| std::overflow_error | if divisor is zero |

Modulo assignment operator.
| other | Divisor |
| std::overflow_error | if divisor is zero |

Multiplication operator.
| other | Right operand |

Multiplication assignment operator.
| other | Right operand to multiply by |

Addition operator.
| other | Right operand |

Addition assignment operator.
| other | Right operand to add |

|
inlinenoexcept |
Unary minus operator.

Subtraction operator.
| other | Right operand |

Subtraction assignment operator.
| other | Right operand to subtract |

Division operator.
| other | Divisor |
| std::overflow_error | if divisor is zero |

Division assignment operator.
| other | Divisor |
| std::overflow_error | if divisor is zero |

|
noexcept |
Less than comparison with Decimal.
| val | Right operand |
|
noexcept |
Less than comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Less than comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Less than comparison with signed 32-bit integer.
| val | Right operand |
|
inlinenoexcept |
Less than comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Less than comparison with unsigned 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with Decimal.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with signed 32-bit integer.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Less than or equal comparison with unsigned 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Three-way comparison operator (C++20).
| other | Right operand to compare with |

Copy assignment operator.
| other | The Int128 object to copy from |

Move assignment operator.
| other | The Int128 object to move from |

|
noexcept |
Equality comparison with Decimal.
| val | Right operand |
|
inlinenoexcept |
Equality operator.
| other | Right operand |

|
noexcept |
Equality comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Equality comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Equality comparison with signed 32-bit integer.
| val | Right operand |
|
inlinenoexcept |
Equality comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Equality comparison with unsigned 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than comparison with Decimal.
| val | Right operand |
|
noexcept |
Greater than comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Greater than comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Greater than comparison with signed 32-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than comparison with unsigned 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with Decimal.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with double-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with single-precision floating-point.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with signed 32-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with signed 64-bit integer.
| val | Right operand |
|
inlinenoexcept |
Greater than or equal comparison with unsigned 64-bit integer.
| val | Right operand |
|
nodiscardnoexcept |
Get internal 32-bit representation.


|
nodiscardnoexcept |
Get upper 64 bits.


|
nodiscardnoexcept |
Get lower 64 bits.


|
nodiscard |
Convert to string with exact precision.

