Abstraction of integral numeric types. That is, types
with no fractional part, including Integer.
The division operation for integral numeric types results
in a remainder. Therefore, integral numeric types have
an operation, denoted by the remainder
operator %, to determine the remainder of any division
operation.
if (n%2==0) {
print("Even!");
}
Division and the remainder operation should satisfy:
x == (x/y)*y + x%yfor any instance y other than 0.
All Integral numeric types are also Enumerable, so
ranges of integral values may be produced using the
measure() and span() operators.
// Iterate from 0 to 100 inclusive
for (i in 0..100) {
print("The square of ``i`` is ``i^2``");
}
// Iterate all indices of the array,
// from 0 to array.size-1
for (i in 0:array.size) {
print(array[i]);
}
Integerno type hierarchy
| Attributes | |
unit | Source Codeshared formal Boolean unitDetermine if the number is the multiplicative identity. |
zero | Source Codeshared formal Boolean zeroDetermine if the number is the additive identity. |
| Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Enumerable<Other> |
Attributes inherited from: Invertible<Other> |
Attributes inherited from: Number<Other> |
Attributes inherited from: Ordinal<Other> |
| Methods | |
divides | Source Codeshared default Boolean divides(Other other)Determine if this number is a factor of the given number. |
modulo | Source Codeshared default Other modulo(Other modulus)The modulo, after dividing this number by the given
number. This differs from Throws
See also Numeric.divided(), remainder() |
remainder | Source Codeshared formal Other remainder(Other other)The remainder, after dividing this number by the given number. See also Numeric.divided(), modulo() |
| Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Comparable<Other> |
Methods inherited from: Enumerable<Other> |
Methods inherited from: Invertible<Other> |
Methods inherited from: Number<Other> |
Methods inherited from: Numeric<Other> |
Methods inherited from: Summable<Other> |