Uint128 class
- Implemented types
Constructors
- Uint128(int value)
-
Builds from a plain Dart int. Must be non-negative (same
constraint as
Uint64.new).factory - Uint128.from(int value)
-
Builds from a plain Dart int, accepting negative values by taking
their two's-complement bit pattern (masked to 128 bits) instead of
throwing like Uint128.new does — e.g.
Uint128.from(-1) == Uint128.max.valuemust itself be a normal double-safe Dart int (|value| <= 2^53); BigInt-free, same limb-splitting negation trick asUint64.from, sign-extended into the high limb.factory - Uint128.fromBigInt(BigInt value)
-
factory
- Uint128.fromUint64(Uint64 value)
-
factory
- Uint128.unsafe(Uint64 _hi, Uint64 _lo)
-
Raw limb constructor — prefer Uint128.new / Uint128.fromBigInt
for arbitrary values.
const
Properties
Methods
-
addChecked(
Uint128 other) → Uint128 -
compareTo(
Uint128 other) → int -
Compares this object to another object.
override
-
mulChecked(
Uint128 other) → Uint128 -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
subChecked(
Uint128 other) → Uint128 -
toBigInt(
) → BigInt -
toBytes(
[Endian endian = Endian.big]) → List< int> - Fixed 16-byte encoding, delegating to each Uint64 limb's own (already web-safe) 8-byte encoding.
-
toHexString(
{bool padded = true}) → String -
toInt(
) → int -
Only safe if the value fits in the hi limb being zero and the lo
limb being double-safe — delegates to
Uint64.toInt()'s own guard, throwing IntegerError otherwise (use toBigInt for the general case). -
toInt128(
) → Int128 -
Same-width bit reinterpretation (two's complement) — e.g.
Uint128.max.toInt128() == Int128.minusOne. -
toInt32(
) → Int32 -
Truncating narrow, then reinterpret (wrapping, like a Rust
as i32cast). -
toInt64(
) → Int64 -
Truncating narrow, then reinterpret (wrapping, like a Rust
as i64cast). -
toString(
) → String -
A string representation of this object.
override
-
toUint256(
) → Uint256 - Zero-extending widen. Always exact.
-
toUint32(
) → Uint32 -
Truncating narrow: keeps only the low 32 bits (wrapping, like a
Rust
as u32cast). -
toUint64(
) → Uint64 -
Truncating narrow: keeps only the low 64 bits (wrapping, like a
Rust
as u64cast).
Operators
-
operator %(
Uint128 other) → Uint128 -
operator &(
Uint128 other) → Uint128 -
operator *(
Uint128 other) → Uint128 -
Multiply, keeping only the low 128 bits (wrapping). Built entirely
from
Uint64.widenMul(the full 64x64->128 product of the low limbs) plus wrapping 64-bit multiplies for the cross terms — the same decompositionUint64.operator*itself uses one level down. -
operator +(
Uint128 other) → Uint128 -
operator -(
Uint128 other) → Uint128 -
operator <(
Uint128 other) → bool -
operator <<(
int n) → Uint128 -
Logical left shift. Each step here is a plain
Uint64shift/bitwise op — already proven web-safe inUint64itself — so no additional safety trick is needed at this width. -
operator <=(
Uint128 other) → bool -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Uint128 other) → bool -
operator >=(
Uint128 other) → bool -
operator >>(
int n) → Uint128 - Logical (unsigned) right shift.
-
operator ^(
Uint128 other) → Uint128 -
operator |(
Uint128 other) → Uint128 -
operator ~(
) → Uint128 -
operator ~/(
Uint128 other) → Uint128