int abstract class
Representation of Dart integers containing integer specific operations and specialization of operations inherited from num.
Integers can be arbitrarily large in Dart.
Note however, that 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.
abstract class int extends num { /** The bit-wise and operator. */ int operator &(int other); /** The bit-wise or operator. */ int operator |(int other); /** The bit-wise xor operator. */ int operator ^(int other); /** The bit-wise negate operator. */ int operator ~(); /** The left shift operator. */ int operator <<(int shiftAmount); /** The right shift operator. */ int operator >>(int shiftAmount); /** Returns true if and only if this integer is even. */ bool get isEven; /** Returns true if and only if this integer is odd. */ bool get isOdd; /** Negate operator. Negating an integer produces an integer. */ int operator -(); /** Returns the absolute value of this integer. */ int abs(); /** For integers the round method is the identify function. */ int round(); /** For integers the floor method is the identify function. */ int floor(); /** For integers the ceil method is the identify function. */ int ceil(); /** For integers the truncate method is the identify function. */ int truncate(); /** * Returns a representation of this [int] value. * * It should always be the case that if [:i:] is an [int] value, * then [:i == int.parse(i.toString()):]. */ String toString(); /** * Parse [source] as an integer literal and return its value. * * Accepts "0x" prefix for hexadecimal numbers, otherwise defaults * to base-10. * * Throws a [FormatException] if [source] is not a valid integer literal. */ external static int parse(String source); }
Extends
num > int
Static Methods
int parse(String source) #
Parse source as an integer literal and return its value.
Accepts "0x" prefix for hexadecimal numbers, otherwise defaults to base-10.
Throws a FormatException if source is not a valid integer literal.
external static int parse(String source);
Properties
Operators
num operator ~/(num other) #
Truncating division operator.
The result of the truncating division a ~/ b
is equivalent to
(a / b).truncate()
.
num operator ~/(num other);
num operator %(num other) #
Euclidean modulo operator.
num operator %(num other);
bool operator <(num other) #
Relational less than operator.
bool operator <(num other);
bool operator <=(num other) #
Relational less than or equal operator.
bool operator <=(num other);
Methods
abstract int compareTo(Comparable other) #
Compares this object to another Comparable
Returns a value like a Comparator when comparing this
to
other.
May throw an ArgumentError if
other is of a type that
is not comparable to this
.
num remainder(num other) #
Return the remainder from dividing this num by other.
num remainder(num other);
String toRadixString(int radix) #
Converts a num to a string representation in the given radix.
The num in converted to an int using toInt
. That int is
then converted to a string representation with the given
radix. In the string representation, lower-case letters are
used for digits above '9'.
The radix argument must be an integer between 2 and 36.
String toRadixString(int radix);
String toStringAsExponential(int fractionDigits) #
Converts a num to a string in decimal exponential notation with fractionDigits digits after the decimal point.
String toStringAsExponential(int fractionDigits);
String toStringAsFixed(int fractionDigits) #
Converts a num to a string representation with fractionDigits digits after the decimal point.
String toStringAsFixed(int fractionDigits);