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 represented 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
, parseInteger()
, formatInteger()
no subtypes hierarchy
Initializer |
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, |
float | Source Codeshared Float float The number, represented as a
Throws
See also runtime.maxExactIntegralFloat |
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 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 |
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) Compares this value with the given value. Implementations must respect the constraints that:
Refines Comparable.compare |
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 results in a remainder. When the given number is Refines Numeric.divided |
divides | Source Codeshared actual Boolean divides(Integer other) Determine if this number is a factor of the given number. 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 |
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 |
leftLogicalShift | Source Codeshared actual Integer leftLogicalShift(Integer shift) If shift is in the range of addressable bits
( Refines Binary.leftLogicalShift |
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 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 |
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. 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 |
remainder | Source Codeshared actual Integer remainder(Integer other) The remainder, after dividing this number by the given number. Refines Integral.remainder |
rightArithmeticShift | Source Codeshared actual Integer rightArithmeticShift(Integer shift) If shift is in the range of addressable bits
( Refines Binary.rightArithmeticShift |
rightLogicalShift | Source Codeshared actual Integer rightLogicalShift(Integer shift) If shift is in the range of addressable bits
( Refines Binary.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 |
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> |