int class - dart:core library (original) (raw)
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 intclass 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:
- num the super class for int.
- Numbers inA tour of the Dart language.
Inheritance
Available extensions
Constructors
int.fromEnvironment(String name, {int defaultValue = 0})
Integer value for name
in the compilation configuration environment.
const
factory
Properties
Available on int, provided by the IntAddress extension
The memory address of the underlying data.
getter/setter pair
Returns the minimum number of bits required to store this integer.
no setter
Returns a hash code for a numerical value.
no setterinherited
Returns true if and only if this integer is even.
no setter
Whether this number is finite.
no setterinherited
Whether this number is positive infinity or negative infinity.
no setterinherited
Whether this number is a Not-a-Number value.
no setterinherited
Whether this number is negative.
no setterinherited
Returns true if and only if this integer is odd.
no setter
A representation of the runtime type of the object.
no setterinherited
Returns the sign of this integer.
no setteroverride
Available on num, provided by the NumToJSExtension extension
Converts this num to a JSNumber.
no setter
Methods
Returns the absolute value of this integer.
override
Returns this
.
override
Returns this.toDouble()
.
override
clamp(num lowerLimit, num upperLimit)→ num
Returns this num clamped to be in the range lowerLimit
-upperLimit
.
inherited
Compares this to other
.
inherited
Returns this
.
override
Returns this.toDouble()
.
override
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
Invoked when a nonexistent method or property is accessed.
inherited
The remainder of the truncating division of this
by other
.
inherited
Returns this
.
override
Returns this.toDouble()
.
override
This number as a double.
inherited
Truncates this num to an integer and returns the result as an int.
inherited
toRadixString(int radix)→ String
Converts this int to a string representation in the given radix
.
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
.
Returns a string representation of this integer.
override
toStringAsExponential([int? fractionDigits])→ String
An exponential string-representation of this number.
inherited
toStringAsFixed(int fractionDigits)→ String
A decimal-point string-representation of this number.
inherited
toStringAsPrecision(int precision)→ String
A string representation with precision
significant digits.
inherited
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
.
Returns this
.
override
Returns this.toDouble()
.
override
Operators
operator %(num other)→ num
Euclidean modulo of this number by other
.
inherited
operator &(int other)→ int
Bit-wise and operator.
operator *(num other)→ num
Multiplies this number by other
.
inherited
operator +(num other)→ num
Adds other
to this number.
inherited
operator -(num other)→ num
Subtracts other
from this number.
inherited
operator /(num other)→ double
Divides this number by other
.
inherited
operator <(num other)→ bool
Whether this number is numerically smaller than other
.
inherited
operator <<(int shiftAmount)→ int
Shift the bits of this integer to the left by shiftAmount
.
operator <=(num other)→ bool
Whether this number is numerically smaller than or equal to other
.
inherited
operator ==(Object other)→ bool
Test whether this value is numerically equal to other
.
inherited
operator >(num other)→ bool
Whether this number is numerically greater than other
.
inherited
operator >=(num other)→ bool
Whether this number is numerically greater than or equal to other
.
inherited
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.
Return the negative value of this integer.
override
operator |(int other)→ int
Bit-wise or operator.
operator ~()→ int
The bit-wise negate operator.
operator ~/(num other)→ int
Truncating division operator.
inherited
Static Methods
parse(String source, {int? radix})→ int
Parse source
as a, possibly signed, integer literal and return its value.
override
tryParse(String source, {int? radix})→ int?
Parse source
as a, possibly signed, integer literal.
override