dart:core
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 values 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.
See also:
- Inheritance
-
Constructors
- int.fromEnvironment(String name, {int defaultValue = 0})
const
factory
- Returns the integer value of the given environment declaration
name.
Properties
- bitLength → int
read-only
- Returns the minimum number of bits required to store this integer.
- hashCode → int
read-only, inherited
- Returns a hash code for a numerical value.
- isEven → bool
read-only
- Returns true if and only if this integer is even.
- isFinite → bool
read-only, inherited
- Whether this number is finite.
- isInfinite → bool
read-only, inherited
- Whether this number is positive infinity or negative infinity.
- isNaN → bool
read-only, inherited
- Whether this number is a Not-a-Number value.
- isNegative → bool
read-only, inherited
- Whether this number is negative.
- isOdd → bool
read-only
- Returns true if and only if this integer is odd.
- runtimeType → Type
read-only, inherited
- A representation of the runtime type of the object.
- sign → int
read-only, override
- Returns the sign of this integer.
Methods
- abs() → int
override
- Returns the absolute value of this integer.
- ceil() → int
override
- Returns
this. - ceilToDouble() → double
override
- Returns
this.toDouble(). - clamp(num lowerLimit, num upperLimit) → num
inherited
- Returns this num clamped to be in the range
lowerLimit-upperLimit. - compareTo(num other) → int
inherited
- Compares this to
other. - floor() → int
override
- Returns
this. - floorToDouble() → double
override
- 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. - noSuchMethod(Invocation invocation) → dynamic
inherited
- Invoked when a non-existent method or property is accessed.
- remainder(num other) → num
inherited
- The remainder of the truncating division of
this by other. - round() → int
override
- Returns
this. - roundToDouble() → double
override
- Returns
this.toDouble(). - toDouble() → double
inherited
- This number as a double.
- toInt() → int
inherited
- Truncates this num to an integer and returns the result as an int.
- 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
override
- Returns a string representation of this integer.
- toStringAsExponential([int? fractionDigits]) → String
inherited
- An exponential string-representation of this number.
- toStringAsFixed(int fractionDigits) → String
inherited
- A decimal-point string-representation of this number.
- toStringAsPrecision(int precision) → String
inherited
- A string representation with
precision 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 than width. - truncate() → int
override
- Returns
this. - truncateToDouble() → double
override
- Returns
this.toDouble().
Operators
- operator %(num other) → num
inherited
- Euclidean modulo of this number by
other. - operator &(int other) → int
- Bit-wise and operator.
- operator *(num other) → num
inherited
- Multiplies this number by
other. - operator +(num other) → num
inherited
- Adds
other to this number. - operator -(num other) → num
inherited
- Subtracts
other from this number. - operator /(num other) → double
inherited
- Divides this number by
other. - operator <(num other) → bool
inherited
- Whether this number is numerically smaller than
other. - operator <<(int shiftAmount) → int
- Shift the bits of this integer to the left by
shiftAmount. - operator <=(num other) → bool
inherited
- Whether this number is numerically smaller than or equal to
other. - operator ==(Object other) → bool
inherited
- Test whether this value is numerically equal to
other. - operator >(num other) → bool
inherited
- Whether this number is numerically greater than
other. - operator >=(num other) → bool
inherited
- Whether this number is numerically greater than or equal to
other. - 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
- Bit-wise exclusive-or operator.
- operator unary-() → int
override
- 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) → int
inherited
- Truncating division operator.
Static Methods
- parse(String source, {int? radix, int onError(String source)?}) → int
override
- Parse
source as a, possibly signed, integer literal and return its value. - tryParse(String source, {int? radix}) → int?
override
- Parse
source as a, possibly signed, integer literal.