class
int

An arbitrarily large integer.

Note: When compiling to JavaScript, integers are implemented as JavaScript numbers. When compiling to JavaScript, integers are therefore restricted to 53 significant bits because all JavaScript numbers are double-precision floating point values. The behavior of the operators and methods in the int class therefore sometimes differs between the Dart VM and Dart code compiled to JavaScript.

It is a compile-time error for a class to attempt to extend or implement int.

Extends

Static Methods

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

Properties

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

Constructors

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

Operators

operator &(int other) → int
Bit-wise and operator.
operator |(int other) → int
Bit-wise or operator.
operator ^(int other) → int
Bit-wise exclusive-or operator.
operator ~() → int
The bit-wise negate 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 unary-() → int
Return the negative value of this integer.
operator ~/(num other) → int
inherited
Truncating division operator.
operator /(num other) → double
inherited
Division operator.
operator <(num other) → bool
inherited
Relational less than operator.
operator >=(num other) → bool
inherited
Relational greater than or equal operator.
operator ==(Object other) → bool
inherited
Test whether this value is numerically equal to other.
operator <=(num other) → bool
inherited
Relational less than or equal operator.
operator >(num other) → bool
inherited
Relational greater than operator.
operator *(num other) → num
inherited
Multiplication operator.
operator -(num other) → num
inherited
Subtraction operator.
operator %(num other) → num
inherited
Euclidean modulo operator.
operator +(num other) → num
inherited
Addition operator.

Methods

modPow(int exponent, int modulus) → int
Returns this integer to the power of exponent modulo modulus.
modInverse(int modulus) → int
Returns the modular multiplicative inverse of this integer modulo modulus.
gcd(int other) → int
Returns the greatest common divisor of this integer and other.
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.
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.
abs() → int
Returns the absolute value of this integer.
round() → int
Returns this.
floor() → int
Returns this.
ceil() → int
Returns this.
truncate() → int
Returns this.
roundToDouble() → double
Returns this.toDouble().
floorToDouble() → double
Returns this.toDouble().
ceilToDouble() → double
Returns this.toDouble().
truncateToDouble() → double
Returns this.toDouble().
toString() → String
Returns a String-representation of this integer.
toRadixString(int radix) → String
Converts this to a string representation in the given radix.
remainder(num other) → num
inherited
Returns the remainder of the truncating division of this by other.
toStringAsFixed(int fractionDigits) → String
inherited
Returns a decimal-point string-representation of this.
toStringAsPrecision(int precision) → String
inherited
Converts this to a double and returns a string representation with exactly precision significant digits.
compareTo(num other) → int
inherited
Compares this to other.
toDouble() → double
inherited
Return this num as a double.
clamp(num lowerLimit, num upperLimit) → num
inherited
Returns this num clamped to be in the range lowerLimit-upperLimit.
toStringAsExponential([int fractionDigits]) → String
inherited
Returns an exponential string-representation of this.
toInt() → int
inherited
Truncates this num to an integer and returns the result as an int.