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. value must itself be a normal double-safe Dart int (|value| <= 2^53); BigInt-free, same limb-splitting negation trick as Uint64.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

hashCode int
The hash code for this object.
no setteroverride
hi Uint64
no setter
isEven bool
no setter
isZero bool
no setter
lo Uint64
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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 i32 cast).
toInt64() Int64
Truncating narrow, then reinterpret (wrapping, like a Rust as i64 cast).
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 u32 cast).
toUint64() Uint64
Truncating narrow: keeps only the low 64 bits (wrapping, like a Rust as u64 cast).

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 decomposition Uint64.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 Uint64 shift/bitwise op — already proven web-safe in Uint64 itself — 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

Static Methods

fromBytes(List<int> bytes, {Endian endian = Endian.big, int offset = 0}) Uint128
parseDecimal(String s) Uint128
Strict decimal parse: throws IntegerError on overflow, unlike the wrapping operators.
parseHex(String s) Uint128

Constants

max → const Uint128
one → const Uint128
zero → const Uint128