An integer number.
The default implementation ofint is 64-bit two's complement integerswith operations that wrap to that range on overflow.
Note: When compiling to JavaScript, integers are restricted to valuesthat 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 largerthan 2^63.The behavior of the operators and methods in theintclass therefore sometimes differs between the Dart VM and Dart codecompiled to JavaScript. For example, the bitwise operators truncate theiroperands to 32-bit integers when compiled to JavaScript.
Classes cannot extend, implement, or mix inint.
See also:
- num the super class forint.
- Numbers inA tour of the Dart language.
- Inheritance
- Available extensions
Constructors
- int.fromEnvironment(Stringname, {intdefaultValue =0})
- Integer value for
namein the compilation configuration environment.constfactory
Properties
- address↔Pointer<
Never> Available onint, provided by theIntAddress extension
The memory address of the underlying data.getter/setter pair- bitLength→int
- Returns the minimum number of bits required to store this integer.no setter
- hashCode→int
- Returns a hash code for a numerical value.no setterinherited
- isEven→bool
- Returns true if and only if this integer is even.no setter
- isFinite→bool
- Whether this number is finite.no setterinherited
- isInfinite→bool
- Whether this number is positive infinity or negative infinity.no setterinherited
- isNaN→bool
- Whether this number is a Not-a-Number value.no setterinherited
- isNegative→bool
- Whether this number is negative.no setterinherited
- isOdd→bool
- Returns true if and only if this integer is odd.no setter
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
- sign→int
- Returns the sign of this integer.no setteroverride
- toJS→JSNumber
Available onnum, provided by theNumToJSExtension extension
Converts thisnum to aJSNumber.no setter
Methods
- abs(
)→int - Returns the absolute value of this integer.override
- ceil(
)→int - Returns
this.override - ceilToDouble(
)→double - Returns
this.toDouble().override - clamp(
numlowerLimit,numupperLimit)→num - Returns thisnum clamped to be in the range
lowerLimit-upperLimit.inherited - compareTo(
numother)→int - Compares this to
other.inherited - floor(
)→int - Returns
this.override - floorToDouble(
)→double - Returns
this.toDouble().override - gcd(
intother)→int - Returns the greatest common divisor of this integer and
other. - modInverse(
intmodulus)→int - Returns the modular multiplicative inverse of this integermodulo
modulus. - modPow(
intexponent,intmodulus)→int - Returns this integer to the power of
exponentmodulomodulus. - noSuchMethod(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- remainder(
numother)→num - The remainder of the truncating division of
thisbyother.inherited - round(
)→int - Returns
this.override - roundToDouble(
)→double - Returns
this.toDouble().override - toDouble(
)→double - This number as adouble.inherited
- toInt(
)→int - Truncates thisnum to an integer and returns the result as anint.inherited
- toRadixString(
intradix)→String - Converts thisint to a string representation in the given
radix. - toSigned(
intwidth)→int - Returns the least significant
widthbits of this integer, extending thehighest retained bit to the sign. This is the same as truncating the valueto fit inwidthbits using an signed 2-s complement representation. Thereturned 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 string-representation of this number.inherited
- toStringAsFixed(
intfractionDigits)→String - A decimal-point string-representation of this number.inherited
- toStringAsPrecision(
intprecision)→String - A string representation with
precisionsignificant digits.inherited - toUnsigned(
intwidth)→int - Returns the least significant
widthbits of this integer as anon-negative number (i.e. unsigned representation). The returned value haszeros in all bit positions higher thanwidth. - truncate(
)→int - Returns
this.override - truncateToDouble(
)→double - Returns
this.toDouble().override
Operators
- operator %(
numother)→num - Euclidean modulo of this number by
other.inherited - operator &(
intother)→int - Bit-wise and operator.
- operator *(
numother)→num - Multiplies this number by
other.inherited - operator +(
numother)→num - Adds
otherto this number.inherited - operator -(
numother)→num - Subtracts
otherfrom this number.inherited - operator /(
numother)→double - Divides this number by
other.inherited - operator<(
numother)→bool - Whether this number is numerically smaller than
other.inherited - operator<<(
intshiftAmount)→int - Shift the bits of this integer to the left by
shiftAmount. - operator<=(
numother)→bool - Whether this number is numerically smaller than or equal to
other.inherited - operator ==(
Objectother)→bool - Test whether this value is numerically equal to
other.inherited - operator >(
numother)→bool - Whether this number is numerically greater than
other.inherited - operator >=(
numother)→bool - Whether this number is numerically greater than or equal to
other.inherited - operator >>(
intshiftAmount)→int - Shift the bits of this integer to the right by
shiftAmount. - operator >>>(
intshiftAmount)→int - Bitwise unsigned right shift by
shiftAmountbits. - operator ^(
intother)→int - Bit-wise exclusive-or operator.
- operator unary-(
)→int - Return the negative value of this integer.override
- operator unary-(
)→num - The negation of this value.inherited
- operator |(
intother)→int - Bit-wise or operator.
- operator ~(
)→int - The bit-wise negate operator.
- operator ~/(
numother)→int - Truncating division operator.inherited