An exact representation of a positive whole number, negative whole number, or zero. The largest and smallest representable values are platform-dependent:
Overflow or loss of precision occurs silently (with no exception raised).
An integer is considered equal to its float
representation, if that exists. That is, for every integer
int
, either int.float
throws an OverflowException
,
or the expression int.float==int
evaluates to true
.
An integer is representable as a sequence of bits. Not all
of the bits in the representation may be addressed by the
methods inherited from Binary
:
Literal integers may be written in decimal, hexadecimal, or binary notation:
8660 #21D4 $10000111010100
Underscores may be used to group digits:
8660 #21_D4 $10_0001_1101_0100
runtime.integerSize
no subtypes hierarchy
Constructors | |
Integer | Source Codeshared Integer(Integer integer) |
Attributes | |
absolute | See magnitude |
byte | Source Codeshared Byte byte |
character | Source Codeshared Character character The UTF-32 character with this UCS code point. Throws
|
even | Source Codeshared Boolean even Determine if this integer is even. An integer i == 2*k Thus, Since 1.1.0 |
float | Source Codeshared Float float The number, represented as a
Throws
See also runtime.maxExactIntegralFloat , nearestFloat Since 1.1.0 |
fractionalPart | Source Codeshared actual Integer fractionalPart The fractional part of this number, after truncation of
the integral part. For Refines Number.fractionalPart |
hash | Source Codeshared actual Integer hash The hash code of this int.hash == int.rightArithmeticShift(32).exclusiveOr(int) Refines Object.hash |
magnitude | Source Codeshared actual Integer magnitude The magnitude of this number, defined for any instance
where
Refines Number.magnitude Aliases: absolute |
nearestFloat | Source Codeshared Float nearestFloat The nearest
This method never throws an See also float Since 1.2.0 |
negated | Source Codeshared actual Integer negated The additive inverse of this value. Refines Invertible.negated |
negative | Source Codeshared actual Boolean negative Determine if the number is strictly negative, that is,
if Refines Number.negative |
not | Source Codeshared actual Integer not The binary complement of this sequence of bits. Refines Binary.not |
positive | Source Codeshared actual Boolean positive Determine if the number is strictly positive, that is,
if Refines Number.positive |
predecessor | Source Codeshared actual Integer predecessor The predecessor of this value. |
sign | Source Codeshared actual Integer sign The sign of this number:
Must satisfy: x.magnitude.timesInteger(x.sign) == x Refines Number.sign |
string | Source Codeshared actual String string A developer-friendly string representing the instance.
Concatenates the name of the concrete class of the
instance with the See also formatInteger() Refines Object.string |
successor | Source Codeshared actual Integer successor The successor of this value. |
unit | Source Codeshared actual Boolean unit Determine if the number is the multiplicative identity. Refines Integral.unit |
wholePart | Source Codeshared actual Integer wholePart The integral value of the number after truncation of
the fractional part. For Refines Number.wholePart |
zero | Source Codeshared actual Boolean zero Determine if the number is the additive identity. Refines Integral.zero |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Binary<Other> |
Attributes inherited from: Enumerable<Other> |
Attributes inherited from: Integral<Other> |
Attributes inherited from: Invertible<Other> |
Attributes inherited from: Number<Other> |
Attributes inherited from: Ordinal<Other> |
Methods | |
and | Source Codeshared actual Integer and(Integer other) Performs a logical AND operation. Refines Binary.and |
clear | Source Codeshared actual Integer clear(Integer index) If the Refines Binary.clear |
compare | Source Codeshared actual Comparison compare(Integer other) Compare this integer with the given integer, returning:
|
divided | Source Codeshared actual Integer divided(Integer other) The quotient obtained by dividing this number by the
given number. For integral numeric types,
this operation rounds toward When the given divisor is exactly Refines Numeric.divided |
divides | Source Codeshared actual Boolean divides(Integer other) Determines if this integer is a factor of the given
integer, that is, if Refines Integral.divides |
equals | Source Codeshared actual Boolean equals(Object that) Determines if the given object is equal to this
Or if:
Refines Object.equals |
flip | Source Codeshared actual Integer flip(Integer index) If the Refines Binary.flip |
format | Source Codeshared static String format(Integer integer, Integer radix = ..., Character? groupingSeparator = null) The string representation of the given For example:
Parameters:
Throws
See also parse() , Float.format() Since 1.3.1 |
get | Source Codeshared actual Boolean get(Integer index) If the Refines Binary.get |
largerThan | Source Codeshared actual Boolean largerThan(Integer other) Determines if this value is strictly larger than the given value. Refines Comparable.largerThan |
largest | Source Codeshared static Integer largest(Integer x, Integer y) The larger of the two given integers. Since 1.3.2 |
leftLogicalShift | Source Codeshared actual Integer leftLogicalShift(Integer shift) If the given 0..runtime.integerAddressableSize-1 shift the addressable bits to the left by shift.and(runtime.integerAddressableSize-1) positions, using zero extension. Refines Binary.leftLogicalShift Aliases: leftShift |
leftShift | See leftLogicalShift() |
max | Source Codeshared static Integer|Absent max<Absent>(Iterable<Integer,Absent> integers) The largest integer in the given stream, or Since 1.3.2 |
min | Source Codeshared static Integer|Absent min<Absent>(Iterable<Integer,Absent> integers) The smallest integer in the given stream, or Since 1.3.2 |
minus | Source Codeshared actual Integer minus(Integer other) The difference between this number and the given
number. Must produce the value Refines Invertible.minus |
modulo | Source Codeshared actual Integer modulo(Integer modulus) The modulo, after dividing this number by the given
number. This differs from Since 1.2.0 Refines Integral.modulo |
neighbour | Source Codeshared actual Integer neighbour(Integer offset) The indirect successor or predecessor at the given
Refines Enumerable.neighbour |
notLargerThan | Source Codeshared actual Boolean notLargerThan(Integer other) Determines if this value is smaller than or equal to the given value. Refines Comparable.notLargerThan |
notSmallerThan | Source Codeshared actual Boolean notSmallerThan(Integer other) Determines if this value is larger than or equal to the given value. Refines Comparable.notSmallerThan |
offset | Source Codeshared actual Integer offset(Integer other) Compute the offset from the given value, where:
Refines Enumerable.offset |
offsetSign | Source Codeshared actual Integer offsetSign(Integer other) The sign of the offset from the given value. Refines Enumerable.offsetSign |
or | Source Codeshared actual Integer or(Integer other) Performs a logical inclusive OR operation. Refines Binary.or |
parse | Source Codeshared static Integer|ParseException parse(String string, Integer radix = ...) The The syntax accepted by this function depends upon the given base:
The given Integer: Base10 | BaseN Base10: Sign? Base10Digits Magnitude BaseN: Sign? BaseNDigits Sign: '+' | '-' Magnitude: 'k' | 'M' | 'G' | 'T' | 'P' Base10Digits: ('0'..'9')+ BaseNDigits: ('0'..'9'|'a'..'z'|'A'..'Z')+ Parameters:
Throws
See also format() , Float.parse() Since 1.3.1 |
plus | Source Codeshared actual Integer plus(Integer other) The result of adding the given value to this value. This operation should never perform any kind of mutation upon either the receiving value or the argument value. For any two instances x + y Refines Summable.plus |
plusInteger | Source Codeshared actual Integer plusInteger(Integer integer) The result of adding this number to the given
Refines Number.plusInteger |
power | Source Codeshared actual Integer power(Integer other) The result of raising this number to the given
non-negative integer power, where Throws
Refines Exponentiable.power |
powerOfInteger | Source Codeshared actual Integer powerOfInteger(Integer integer) The result of raising this number to the given
non-negative integer power, where Throws
Refines Number.powerOfInteger |
product | Source Codeshared static Integer product({Integer*} integers) The product of all the integers in the given stream, or
Since 1.3.2 |
remainder | Source Codeshared actual Integer remainder(Integer other) The remainder, after dividing this number by the given number. The sign of the remainder depends upon the sign of this number, and of the argument divisor:
Thus, in order to satisfy the identity
Refines Integral.remainder |
rightArithmeticShift | Source Codeshared actual Integer rightArithmeticShift(Integer shift) If the given 0..runtime.integerAddressableSize-1 shift the addressable bits to the right by shift.and(runtime.integerAddressableSize-1) positions, using sign extension. Refines Binary.rightArithmeticShift |
rightLogicalShift | Source Codeshared actual Integer rightLogicalShift(Integer shift) If the given 0..runtime.integerAddressableSize-1 shift the addressable bits to the right by shift.and(runtime.integerAddressableSize-1) positions, using zero extension. Refines Binary.rightLogicalShift Aliases: rightShift |
rightShift | See rightLogicalShift() |
set | Source Codeshared actual Integer set(Integer index, Boolean bit) If the Refines Binary.set |
smallerThan | Source Codeshared actual Boolean smallerThan(Integer other) Determines if this value is strictly smaller than the given value. Refines Comparable.smallerThan |
smallest | Source Codeshared static Integer smallest(Integer x, Integer y) The smaller of the two given integers. Since 1.3.2 |
sum | Source Codeshared static Integer sum({Integer*} integers) The sum of all the integers in the given stream, or
Since 1.3.2 |
times | Source Codeshared actual Integer times(Integer other) The product of this number and the given number. Refines Numeric.times |
timesInteger | Source Codeshared actual Integer timesInteger(Integer integer) The result of multiplying this number by the given
Refines Number.timesInteger |
xor | Source Codeshared actual Integer xor(Integer other) Performs a logical exclusive OR operation. Refines Binary.xor |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Binary<Other> |
Methods inherited from: Comparable<Other> |
Methods inherited from: Enumerable<Other> |
Methods inherited from: Exponentiable<This,Other> |
Methods inherited from: Integral<Other> |
Methods inherited from: Invertible<Other> |
Methods inherited from: Number<Other> |
Methods inherited from: Numeric<Other> |
Methods inherited from: Summable<Other> |