Uint256 class

Implemented types

Constructors

Uint256(int value)
Builds from a plain Dart int. Must be non-negative (same constraint as Uint64.new).
factory
Uint256.from(int value)
Builds from a plain Dart int, accepting negative values by taking their two's-complement bit pattern (masked to 256 bits) instead of throwing like Uint256.new does — e.g. Uint256.from(-1) == Uint256.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 three high limbs.
factory
Uint256.fromBigInt(BigInt value)
factory
Uint256.fromUint64(Uint64 value)
factory
Uint256.unsafe(Uint64 _d3, Uint64 _d2, Uint64 _d1, Uint64 _d0)
Raw limb constructor (most-significant limb first) — prefer Uint256.new / Uint256.fromBigInt for arbitrary values.
const

Properties

d0 Uint64
no setter
d1 Uint64
no setter
d2 Uint64
no setter
d3 Uint64
no setter
hashCode int
The hash code for this object.
no setteroverride
isEven bool
no setter
isOdd bool
no setter
isZero bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addChecked(Uint256 other) Uint256
compareTo(Uint256 other) int
Compares this object to another object.
override
mulChecked(Uint256 other) Uint256
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subChecked(Uint256 other) Uint256
toBigInt() BigInt
toBytes([Endian endian = Endian.big]) List<int>
Fixed 32-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 top three limbs are zero and the low limb is double-safe — delegates to Uint64.toInt()'s own guard, throwing IntegerError otherwise (use toBigInt for the general case).
toInt128() Int128
Truncating narrow, then reinterpret (wrapping, like a Rust as i128 cast).
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
toUint128() Uint128
Truncating narrow: keeps only the low 128 bits (wrapping, like a Rust as u128 cast).
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 %(Uint256 other) Uint256
operator &(Uint256 other) Uint256
operator *(Uint256 other) Uint256
Multiply, keeping only the low 256 bits (wrapping). Row-scanning (operand-scanning) schoolbook multiply: for each limb a[i] of this, walk every limb b[j] of other and accumulate a[i]*b[j] into acc[i+j], threading carry from acc[i+j] to acc[i+j+1] via Uint64.mac — the same single-carry-chain pattern Uint64.operator* itself uses one level down (multiply one operand by a single digit of the other, adding into a result array with carry propagating to the next position).
operator +(Uint256 other) Uint256
operator -(Uint256 other) Uint256
operator <(Uint256 other) bool
operator <<(int n) Uint256
Logical left shift, generalized across limb boundaries. Every step 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 <=(Uint256 other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(Uint256 other) bool
operator >=(Uint256 other) bool
operator >>(int n) Uint256
Logical (unsigned) right shift, generalized across limb boundaries.
operator ^(Uint256 other) Uint256
operator unary-() Uint256
operator |(Uint256 other) Uint256
operator ~() Uint256
operator ~/(Uint256 other) Uint256

Static Methods

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

Constants

max → const Uint256
one → const Uint256
two → const Uint256
zero → const Uint256