|
nfx-datatypes 0.1.1
Cross-platform C++ library with high-precision Int128 and Decimal datatypes
|
Cross-platform 128-bit integer arithmetic type. More...
#include <array>#include <compare>#include <cstdint>#include <optional>#include <string>#include <string_view>#include "nfx/detail/datatypes/CompilerSupport.h"#include "nfx/detail/datatypes/Int128.inl"

Go to the source code of this file.
Classes | |
| class | nfx::datatypes::Int128 |
| Cross-platform 128-bit signed integer type. More... | |
Functions | |
| Int128 | nfx::datatypes::abs (const Int128 &value) noexcept |
| Get absolute value of Int128 (free function). | |
| Int128 | nfx::datatypes::isqrt (const Int128 &value) |
| Calculate integer square root (free function). | |
| Decimal | nfx::datatypes::sqrt (const Int128 &value) |
| Calculate square root of Int128 value with high precision. | |
Cross-platform 128-bit integer arithmetic type.
Provides portable 128-bit signed integer operations with native __int128 on GCC/Clang and manual implementation on MSVC
Integration with Decimal:
The 128-bit signed integer uses two's complement representation:
Where:
Value Range:
Example 1: Small positive number (42)
Example 2: Large positive number (12,345,678,901,234,567,890)
Example 3: Very large number requiring full 128 bits
Example 4: Negative number (-42)
Definition in file Int128.h.
|
inlinenodiscardnoexcept |
Get absolute value of Int128 (free function).
| value | Int128 to get absolute value of |
Free function wrapper for generic programming and ADL (Argument-Dependent Lookup). Enables usage in generic algorithms: abs(value) works via ADL.
|
inlinenodiscard |
Calculate integer square root (free function).
| value | Int128 to compute square root of |
| std::domain_error | if value is negative |
Free function wrapper for generic programming and ADL (Argument-Dependent Lookup). Returns floor(sqrt(value)) - always rounds down.
Definition at line 805 of file Int128.h.

|
nodiscard |
Calculate square root of Int128 value with high precision.
| value | Integer value to compute square root of |
| std::domain_error | if value is negative |
Converts Int128 to Decimal and computes high-precision square root using Newton-Raphson method. This provides exact decimal precision (up to 28 digits) compared to isqrt() which returns floor(sqrt).
Examples: