int class Null safety
An integer number.
The default implementation of int
is 64bit two's complement integers
with operations that wrap to that range on overflow.
Note: When compiling to JavaScript, integers are restricted to values that can be represented exactly by doubleprecision floating point values. The available integer values include all integers between 2^53 and 2^53, and some integers with larger magnitude. That includes some integers larger than 2^63. The behavior of the operators and methods in the int class therefore sometimes differs between the Dart VM and Dart code compiled to JavaScript. For example, the bitwise operators truncate their operands to 32bit integers when compiled to JavaScript.
Classes cannot extend, implement, or mix in int
.
See also:
 num the super class for int.
 Numbers in A tour of the Dart language.
 Inheritance
 Available Extensions
Constructors
 int.fromEnvironment(String name, {int defaultValue = 0})

Returns the integer value of the given environment declaration
name
.constfactory
Properties
 bitLength → int

Returns the minimum number of bits required to store this integer.
readonly
 hashCode → int

Returns a hash code for a numerical value.
readonlyinherited
 isEven → bool

Returns true if and only if this integer is even.
readonly
 isFinite → bool

Whether this number is finite.
readonlyinherited
 isInfinite → bool

Whether this number is positive infinity or negative infinity.
readonlyinherited
 isNaN → bool

Whether this number is a NotaNumber value.
readonlyinherited
 isNegative → bool

Whether this number is negative.
readonlyinherited
 isOdd → bool

Returns true if and only if this integer is odd.
readonly
 runtimeType → Type

A representation of the runtime type of the object.
readonlyinherited
 sign → int

Returns the sign of this integer.
readonlyoverride
Methods

abs(
) → int 
Returns the absolute value of this integer.
override

ceil(
) → int 
Returns
this
.override 
ceilToDouble(
) → double 
Returns
this.toDouble()
.override 
clamp(
num lowerLimit, num upperLimit) → num 
Returns this num clamped to be in the range
lowerLimit
upperLimit
.inherited 
compareTo(
num other) → int 
Compares this to
other
.inherited 
floor(
) → int 
Returns
this
.override 
floorToDouble(
) → double 
Returns
this.toDouble()
.override 
gcd(
int other) → int 
Returns the greatest common divisor of this integer and
other
. 
modInverse(
int modulus) → int 
Returns the modular multiplicative inverse of this integer
modulo
modulus
. 
modPow(
int exponent, int modulus) → int 
Returns this integer to the power of
exponent
modulomodulus
. 
noSuchMethod(
Invocation invocation) → dynamic 
Invoked when a nonexistent method or property is accessed.
inherited

remainder(
num other) → num 
The remainder of the truncating division of
this
byother
.inherited 
round(
) → int 
Returns
this
.override 
roundToDouble(
) → double 
Returns
this.toDouble()
.override 
toDouble(
) → double 
This number as a double.
inherited

toInt(
) → int 
Truncates this num to an integer and returns the result as an int.
inherited

toRadixString(
int radix) → String 
Converts this to a string representation in the given
radix
. 
toSigned(
int width) → int 
Returns the least significant
width
bits of this integer, extending the highest retained bit to the sign. This is the same as truncating the value to fit inwidth
bits using an signed 2s complement representation. The returned value has the same bit value in all positions higher thanwidth
. 
toString(
) → String 
Returns a string representation of this integer.
override

toStringAsExponential(
[int? fractionDigits]) → String 
An exponential stringrepresentation of this number.
inherited

toStringAsFixed(
int fractionDigits) → String 
A decimalpoint stringrepresentation of this number.
inherited

toStringAsPrecision(
int precision) → String 
A string representation with
precision
significant digits.inherited 
toUnsigned(
int width) → int 
Returns the least significant
width
bits of this integer as a nonnegative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher thanwidth
. 
truncate(
) → int 
Returns
this
.override 
truncateToDouble(
) → double 
Returns
this.toDouble()
.override
Operators

operator %(
num other) → num 
Euclidean modulo of this number by
other
.inherited 
operator &(
int other) → int  Bitwise and operator.

operator *(
num other) → num 
Multiplies this number by
other
.inherited 
operator +(
num other) → num 
Adds
other
to this number.inherited 
operator (
num other) → num 
Subtracts
other
from this number.inherited 
operator /(
num other) → double 
Divides this number by
other
.inherited 
operator <(
num other) → bool 
Whether this number is numerically smaller than
other
.inherited 
operator <<(
int shiftAmount) → int 
Shift the bits of this integer to the left by
shiftAmount
. 
operator <=(
num other) → bool 
Whether this number is numerically smaller than or equal to
other
.inherited 
operator ==(
Object other) → bool 
Test whether this value is numerically equal to
other
.inherited 
operator >(
num other) → bool 
Whether this number is numerically greater than
other
.inherited 
operator >=(
num other) → bool 
Whether this number is numerically greater than or equal to
other
.inherited 
operator >>(
int shiftAmount) → int 
Shift the bits of this integer to the right by
shiftAmount
. 
operator >>>(
int shiftAmount) → int 
Bitwise unsigned right shift by
shiftAmount
bits. 
operator ^(
int other) → int  Bitwise exclusiveor operator.

operator unary(
) → int 
Return the negative value of this integer.
override

operator (
int other) → int  Bitwise or operator.

operator ~(
) → int  The bitwise negate operator.

operator ~/(
num other) → int 
Truncating division operator.
inherited