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.
Static Methods
Properties
- int bitLength
-
read-onlyReturns the minimum number of bits required to store this integer.
- bool isEven
-
read-onlyReturns true if and only if this integer is even.
- bool isFinite
-
read-only, inheritedTrue if the number is finite; otherwise, false.
- bool isInfinite
-
read-only, inheritedTrue if the number is positive infinity or negative infinity; otherwise, false.
- bool isNaN
-
read-only, inheritedTrue if the number is the double Not-a-Number value; otherwise, false.
- bool isNegative
-
read-only, inheritedTrue if the number is negative; otherwise, false.
- bool isOdd
-
read-onlyReturns true if and only if this integer is odd.
- int sign
-
read-onlyReturns the sign of this integer.
Constructors
- int.fromEnvironment(String name, {int defaultValue})
-
constReturns the integer value of the given environment declaration
name
.
Operators
-
operator %(
num other) → num -
inheritedEuclidean modulo operator.
-
operator &(
int other) → int - Bit-wise and operator.
-
operator *(
num other) → num -
inheritedMultiplication operator.
-
operator +(
num other) → num -
inheritedAddition operator.
-
operator -(
num other) → num -
inheritedSubtraction operator.
-
operator /(
num other) → double -
inheritedDivision operator.
-
operator <(
num other) → bool -
inheritedRelational less than operator.
-
operator <<(
int shiftAmount) → int -
Shift the bits of this integer to the left by
shiftAmount
. -
operator <=(
num other) → bool -
inheritedRelational less than or equal operator.
-
operator ==(
Object other) → bool -
inheritedTest whether this value is numerically equal to
other
. -
operator >(
num other) → bool -
inheritedRelational greater than operator.
-
operator >=(
num other) → bool -
inheritedRelational greater than or equal operator.
-
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 ^(
int other) → int - Bit-wise exclusive-or operator.
-
operator |(
int other) → int - Bit-wise or operator.
-
operator ~(
) → int - The bit-wise negate operator.
-
operator ~/(
num other) → int -
inheritedTruncating division operator.
Methods
-
abs(
) → int - Returns the absolute value of this integer.
-
ceil(
) → int -
Returns
this
. -
ceilToDouble(
) → double -
Returns
this.toDouble()
. -
clamp(
num lowerLimit, num upperLimit) → num -
inheritedReturns this num clamped to be in the range
lowerLimit
-upperLimit
. -
compareTo(
num other) → int -
inheritedCompares this to
other
. -
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
modulomodulus
. -
remainder(
num other) → num -
inheritedReturns the remainder of the truncating division of
this
byother
. -
round(
) → int -
Returns
this
. -
roundToDouble(
) → double -
Returns
this.toDouble()
. -
toDouble(
) → double -
inheritedReturn this num as a double.
-
toInt(
) → int -
inheritedTruncates this num to an integer and returns the result as an int.
-
toRadixString(
int radix) → String -
Converts
this
to a string representation in the givenradix
. -
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 2-s complement representation. The returned value has the same bit value in all positions higher thanwidth
. -
toString(
) → String - Returns a String-representation of this integer.
-
toStringAsExponential(
[int fractionDigits]) → String -
inheritedReturns an exponential string-representation of
this
. -
toStringAsFixed(
int fractionDigits) → String -
inheritedReturns a decimal-point string-representation of
this
. -
toStringAsPrecision(
int precision) → String -
inheritedConverts
this
to a double and returns a string representation with exactlyprecision
significant digits. -
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 thanwidth
. -
truncate(
) → int -
Returns
this
. -
truncateToDouble(
) → double -
Returns
this.toDouble()
.