int class

An integer number.

The default implementation of int is 64-bit two's complement integers with operations that wrap to that range on overflow.

Note: When compiling to JavaScript, integers are restricted to valus that can be represented exactly by double-precision 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 32-bit integers when compiled to JavaScript.

Classes cannot extend, implement, or mix in int.

Inheritance

Constructors

int.fromEnvironment(String name, { int defaultValue })
Returns the integer value of the given environment declaration name. [...]
const
factory

Properties

bitLength int
Returns the minimum number of bits required to store this integer. [...]
read-only
isEven bool
Returns true if and only if this integer is even.
read-only
isOdd bool
Returns true if and only if this integer is odd.
read-only
sign int
Returns the sign of this integer. [...]
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
isFinite bool
True if the number is finite; otherwise, false. [...]
read-only, inherited
isInfinite bool
True if the number is positive infinity or negative infinity; otherwise, false.
read-only, inherited
isNaN bool
True if the number is the double Not-a-Number value; otherwise, false.
read-only, inherited
isNegative bool
True if the number is negative; otherwise, false. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

abs() int
Returns the absolute value of this integer. [...]
ceil() int
Returns this.
ceilToDouble() double
Returns this.toDouble().
floor() int
Returns this.
floorToDouble() double
Returns this.toDouble().
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 modulo modulus. [...]
round() int
Returns this.
roundToDouble() double
Returns this.toDouble().
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 in width bits using an signed 2-s complement representation. The returned value has the same bit value in all positions higher than width. [...]
toString() String
Returns a String-representation of this integer. [...]
toUnsigned(int width) int
Returns the least significant width bits of this integer as a non-negative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher than width. [...]
truncate() int
Returns this.
truncateToDouble() double
Returns this.toDouble().
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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
remainder(num other) num
Returns the remainder of the truncating division of this by other. [...]
inherited
toDouble() double
Return this num as a double. [...]
inherited
toInt() int
Truncates this num to an integer and returns the result as an int.
inherited
toStringAsExponential([int fractionDigits ]) String
Returns an exponential string-representation of this. [...]
inherited
toStringAsFixed(int fractionDigits) String
Returns a decimal-point string-representation of this. [...]
inherited
toStringAsPrecision(int precision) String
Converts this to a double and returns a string representation with exactly precision significant digits. [...]
inherited

Operators

operator &(int other) int
Bit-wise and operator. [...]
operator <<(int shiftAmount) int
Shift the bits of this integer to the left by shiftAmount. [...]
operator >>(int shiftAmount) int
Shift the bits of this integer to the right by shiftAmount. [...]
operator ^(int other) int
Bit-wise exclusive-or operator. [...]
operator unary-() int
Return the negative value of this integer. [...]
operator |(int other) int
Bit-wise or operator. [...]
operator ~() int
The bit-wise negate operator. [...]
operator %(num other) num
Euclidean modulo operator. [...]
inherited
operator *(num other) num
Multiplication operator.
inherited
operator +(num other) num
Addition operator.
inherited
operator -(num other) num
Subtraction operator.
inherited
operator /(num other) double
Division operator.
inherited
operator <(num other) bool
Relational less than operator.
inherited
operator <=(num other) bool
Relational less than or equal operator.
inherited
operator ==(dynamic other) bool
The equality operator. [...]
inherited
operator >(num other) bool
Relational greater than operator.
inherited
operator >=(num other) bool
Relational greater than or equal operator.
inherited
operator ~/(num other) int
Truncating division operator. [...]
inherited

Static Methods

parse(String source, { int radix, int onError(String source) }) int
Parse source as a, possibly signed, integer literal and return its value. [...]
tryParse(String source, { int radix }) int
Parse source as a, possibly signed, integer literal and return its value. [...]