Int32 class

Implemented types

Constructors

Int32(int value)
Builds from a plain Dart int (positive or negative), truncating to 32 bits like a wrapping cast. value must itself be a normal, double-safe Dart int (true for any literal or value that didn't already come from a wider fixed-width type).
factory
Int32.fromBigInt(BigInt value)
factory
Int32.unsafe(int _bits)
Raw bit-pattern constructor — bits must already be in [0, 0xFFFFFFFF]. Prefer Int32.new for arbitrary Dart ints.
const

Properties

bits → int
no setter
hashCode → int
The hash code for this object.
no setteroverride
isEven → bool
no setter
isNegative → bool
no setter
isZero → bool
no setter
rawBits → int
Raw two's-complement bit pattern as an unsigned int (0..0xFFFFFFFF).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

abs() → Int32
addChecked(Int32 other) → Int32
compareTo(Int32 other) → int
Compares this object to another object.
override
mulChecked(Int32 other) → Int32
Detects overflow via round-trip: wrap-multiply then divide back out — same technique every sibling mulChecked uses, BigInt-free.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subChecked(Int32 other) → Int32
-other wraps back to Int32.min itself when other == Int32.min (there's no positive counterpart in two's complement), so that case can't go through addChecked(-other) like every other value can. this - Int32.min only fits the signed range when this is negative, in which case the plain wrapping subtract is already exact (never actually wraps).
toBigInt() → BigInt
toBytes([Endian endian = Endian.big]) → List<int>
toDouble() → double
toHexString({bool padded = true}) → String
toInt() → int
Always safe: _bits is always < 2^32, far inside the double-safe integer range, so this is just a sign-extension, never a precision concern.
toInt128() → Int128
Sign-extending widen (via toInt64).
toInt64() → Int64
Sign-extending widen, then reinterpret — e.g. Int32.minusOne widens to all-ones, so toUint64() is Uint64.max, not Uint32.max.
toString() → String
A string representation of this object.
override
toUint128() → Uint128
Sign-extending widen (via toInt64), then reinterpret.
toUint256() → Uint256
Sign-extending widen (via toInt64), then reinterpret.
toUint32() → Uint32
Same-width bit reinterpretation (two's complement) — e.g. Int32.minusOne.toUint32() == Uint32.max.
toUint64() → Uint64
Sign-extending widen (via toInt64's bit pattern), then reinterpret.
toUint8() → int

Operators

operator %(Int32 other) → Int32
Truncating remainder (same sign as the dividend), consistent with operator ~/ above — this is remainder() semantics, not Dart's Euclidean %.
operator &(Int32 other) → Int32
operator *(Int32 other) → Int32
Multiply, keeping only the low 32 bits (wrapping). Two 32-bit magnitudes multiplied directly can reach ~2^64 — unsafe as a double on web — so this decomposes into 16-bit limbs first, the same way Uint64.operator* does.
operator +(Int32 other) → Int32
operator -(Int32 other) → Int32
operator <(Int32 other) → bool
operator <<(int n) → Int32
Logical left shift (bits shifted out the top are discarded).
operator <=(Int32 other) → bool
operator ==(Object other) → bool
The equality operator.
override
operator >(Int32 other) → bool
operator >=(Int32 other) → bool
operator >>(int n) → Int32
Arithmetic (sign-propagating) right shift.
operator >>>(int n) → Int32
Logical (unsigned) right shift — top bits filled with zero regardless of sign.
operator ^(Int32 other) → Int32
operator unary-() → Int32
operator |(Int32 other) → Int32
operator ~() → Int32
operator ~/(Int32 other) → Int32
Truncating division (toward zero), like Rust's / or C's /. Int32.min ~/ Int32.minusOne wraps back to Int32.min (the one case where the mathematical quotient doesn't fit).

Static Methods

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

Constants

mask8 → const Int32
max → const Int32
min → const Int32
minusOne → const Int32
one → const Int32
zero → const Int32