Class BigInt#

Class Documentation#

class BigInt#

An immutable integer, stored inline whenever it fits int64_t.

Heap values lie outside the int64_t range, so inline and heap representations cannot be equal.

ArrayView borrows least-significant-word-first int64_t words; its storage must outlive the view.

Arithmetic has unbounded signed integer semantics, subject to allocation limits. / and % truncate toward zero; floordiv and floormod round the quotient down. Bitwise operations use infinite two’s-complement sign extension. Right shifts round down, and negative shift counts are errors. Floating conversions are explicit.

Public Functions

inline BigInt()#

Construct the integer zero in the inline representation.

template<typename Int, std::enable_if_t<(std::is_integral_v<Int> && sizeof(Int) <= 8), int> = 0>
BigInt(Int value)#

Construct an integer, stored inline when representable as int64_t.

Parameters:

value – Integral input of at most 64 bits, preserved exactly.

explicit BigInt(double value)#

Convert a finite double to an integer, truncating toward zero.

Parameters:

value – Finite input; NaN raises ValueError and infinity raises OverflowError.

inline BigInt(const BigInt &other)#

Copy the value, sharing immutable heap storage when present.

inline BigInt(BigInt &&other) noexcept#

Transfer the value and reset the source to zero.

inline ~BigInt()#
inline void swap(BigInt &other) noexcept#

Exchange values and storage ownership without changing reference counts.

template<typename Int, std::enable_if_t<(std::is_integral_v<Int> && sizeof(Int) <= 8), int> = 0>
std::optional<Int> as() const#

Return an integer conversion when the value fits the requested type.

uint64_t hash() const#

Return a hash of the integer value.