Int64 class

Implemented types

Constructors

Int64(int value)
Builds from a plain Dart int (positive or negative). 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) — i.e. |value| <= 2^53, so splitting it into hi/lo limbs with plain arithmetic operators never forms an intermediate exceeding the JS double-precision safe integer boundary.
factory
Int64.fromBigInt(BigInt value)
Builds from an arbitrary signed BigInt, truncating to 64 bits like a wrapping cast — mirrors Int32.fromBigInt / Int128.fromBigInt. BigInt.toUnsigned gives the exact two's-complement bit pattern directly, so this is correct for any magnitude/sign.
factory
Int64.unsafe(Uint64 bits)
Raw bit-pattern constructor for an already-computed two's-complement Uint64 pattern. Prefer Int64.new otherwise.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
isEven bool
no setter
isNegative bool
no setter
isZero bool
no setter
rawBits Uint64
Raw two's-complement bit pattern as a Uint64.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toI32 Int32
no setter

Methods

abs() Int64
addChecked(Int64 other) Int64
compareTo(Int64 other) int
Flips the sign bit on both operands, which turns two's-complement ordering into plain unsigned ordering — then delegates to Uint64.compareTo.
override
mulChecked(Int64 other) Int64
Detects overflow via round-trip: wrap-multiply then divide back out. Avoids ever forming a >64-bit intermediate. Detects overflow via round-trip: wrap-multiply then divide back out. Avoids ever forming a >64-bit intermediate.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subChecked(Int64 other) Int64
-other wraps back to Int64.min itself when other == Int64.min (no positive counterpart in two's complement), so that case can't go through addChecked(-other) like every other value can. this - Int64.min only fits the signed range when this is negative, in which case the plain wrapping subtract is already exact.
toBigInt() BigInt
Signed value as a BigInt — the general-purpose conversion, unlike toInt which throws when the magnitude doesn't fit a double-safe int. Mirrors Int32.toBigInt / Int128.toBigInt.
toBytes([Endian endian = Endian.big]) List<int>
Fixed 8-byte two's-complement encoding — identical bit-for-bit to Uint64.toBytes, so this just delegates.
toHexString({bool padded = true}) String
toInt() int
Safe only if the magnitude fits in 53 bits — delegates to Uint64.toInt()'s own guard, so it throws IntegerError otherwise.
toInt128() Int128
Sign-extending widen — same bit pattern as toUint128, just relabelled signed.
toInt32() Int32
Truncating narrow, then reinterpret (wrapping, like a Rust as i32 cast). Same value as the toI32 getter, kept for naming consistency with the other toIntNN/toUintNN converters.
toString() String
A string representation of this object.
override
toUint128() Uint128
Sign-extending widen, then reinterpret.
toUint256() Uint256
Sign-extending widen, then reinterpret.
toUint32() Uint32
Truncating narrow, then reinterpret (wrapping, like a Rust as u32 cast).
toUint64() Uint64
Same-width bit reinterpretation (two's complement) — e.g. Int64.minusOne.toUint64() == Uint64.max.
toUint8() int
unsignedShiftRight(int n) Int64
Logical (unsigned) right shift — top bits filled with zero regardless of sign.

Operators

operator %(Int64 other) Int64
Truncating remainder (same sign as the dividend), consistent with operator ~/ above — this is remainder() semantics, not Dart's Euclidean %.
operator &(Int64 other) Int64
operator *(Int64 other) Int64
operator +(Int64 other) Int64
operator -(Int64 other) Int64
operator <(Int64 other) bool
operator <<(int n) Int64
Logical left shift (bits shifted out the top are discarded) — identical for signed and unsigned, delegates to Uint64.
operator <=(Int64 other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(Int64 other) bool
operator >=(Int64 other) bool
operator >>(int n) Int64
Arithmetic (sign-propagating) right shift.
operator ^(Int64 other) Int64
operator unary-() Int64
operator |(Int64 other) Int64
operator ~() Int64
operator ~/(Int64 other) Int64
Truncating division (toward zero), like Rust's / or C's /. Int64.min ~/ Int64.minusOne wraps back to Int64.min (the one case where the mathematical quotient doesn't fit).

Static Methods

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

Constants

mask8 → const Int64
max → const Int64
min → const Int64
minusOne → const Int64
one → const Int64
two → const Int64
zero → const Int64