Basic types Numbers

An exact representation of a positive whole number, negative whole number, or zero. The largest and smallest representable values are platform-dependent:

- For the JVM runtime, integer values between -263 and 263-1 may be represented without overflow.
- For the JavaScript runtime, integer values with a magnitude no greater than 253 may be represented without loss of precision.

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`:

- For the JVM runtime, the bits at all indices (0 to 63) are addressable.
- For the JavaScript runtime, the bits at indices 0 to 31 are addressable.

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

See also `runtime.integerSize`, `parseInteger()`, `formatInteger()`

- `Anything`
  - `Object`
    - `Integer` ...and other supertypes

- `Integer`
  - `Binary`
  - `Exponentiable`
    - `Numeric`
      - `Invertible`
        - `Summable`
  - `Integral`
    - `Enumerable`
      - `Ordinal`
    - `Number`
      - `Comparable`
      - `Numeric`
        - `Invertible`
          - `Summable`
  - `Object`
    - `Anything`

no subtypes hierarchy

Initializer
`Integer(Integer integer)`

Attributes
`absolute` | See `magnitude`
`byte` | Source Code `shared Byte byte` A `Byte` whose signed and unsigned interpretations are congruent modulo 256 to this integer.
`character` | Source Code `shared Character character` The UTF-32 character with this UCS code point. Throws `OverflowException` if this integer is not in the range `0..#10FFFF` of legal Unicode code points
`even` | Source Code `shared Boolean even` Determine if this integer is even. An integer `i` is even if there exists an integer `k` such that:
    i == 2*k
Thus, `i` is even if and only if `i%2 == 0`.
- `float` | Source Code `shared Float float` The number, represented as a `Float`, if such a representation is possible. Any integer with `magnitude` smaller than `runtime.maxExactIntegralFloat` (253) has such a representation. For larger integers on the JVM platform, an `OverflowException` is thrown. Throws `OverflowException` if the number cannot be represented as a `Float` without loss of precision, that is, if
      this.magnitude>runtime.maxExactIntegralFloat
See also `runtime.maxExactIntegralFloat`
`fractionalPart` | Source Code `shared actual Integer fractionalPart` The fractional part of this number, after truncation of the integral part. For `Integral` numeric types, the fractional part is always zero. Refines `Number.fractionalPart`
`hash` | Source Code `shared actual Integer hash` The hash code of this `Integer`, which is just the `Integer` itself, except on the JVM platform where, as with all `hash` codes, this 64-bit `Integer` value is truncated to 32 bits by removal of the 32 higher-order bits. Refines `Object.hash`
`magnitude` | Source Code `shared actual Integer magnitude` The magnitude of this number, defined for any instance `x` as: `-x` if `x<0`, or `x` otherwise, where `0` is the additive identity. Hence: `x.magnitude >= 0` for any `x`, and `x.magnitude == 0` if and only if `x==0`. Refines `Number.magnitude` Aliases: `absolute`
`nearestFloat` | Source Code `shared Float nearestFloat` The nearest `Float` to this number. For any integer with `magnitude` smaller than `runtime.maxExactIntegralFloat` (253), this is a `Float` with the exact same mathematical value (and the same value as `float`). For larger integers on the JVM platform, the `Floats` are less dense than the `Integers` so there may be loss of precision. This method never throws an `OverflowException`.
`negated` | Source Code `shared actual Integer negated` The additive inverse of this value. Refines `Invertible.negated`
`negative` | Source Code `shared actual Boolean negative` Determine if the number is strictly negative, that is, if `this<0`, where `0` is the additive identity. Refines `Number.negative`
`not` | Source Code `shared actual Integer not` The binary complement of this sequence of bits. Refines `Binary.not`
`positive` | Source Code `shared actual Boolean positive` Determine if the number is strictly positive, that is, if `this>0`, where `0` is the additive identity. Refines `Number.positive`
`predecessor` | Source Code `shared actual Integer predecessor` The predecessor of this value. Refines `Enumerable.predecessor` ultimately refines `Ordinal.predecessor`
`sign` | Source Code `shared actual Integer sign` The sign of this number: `1` if the number is `Number.positive`, `-1` if it is `Number.negative`, or `0` if it is the additive identity. Must satisfy:
    x.magnitude.timesInteger(x.sign) == x
Refines `Number.sign`
`string` | Source Code `shared actual String string` A developer-friendly string representing the instance. Concatenates the name of the concrete class of the instance with the `hash` of the instance. Subclasses are encouraged to refine this implementation to produce a more meaningful representation. See also `formatInteger()` Refines `Object.string`
`successor` | Source Code `shared actual Integer successor` The successor of this value. Refines `Enumerable.successor` ultimately refines `Ordinal.successor`
`unit` | Source Code `shared actual Boolean unit` Determine if the number is the multiplicative identity. Refines `Integral.unit`
`wholePart` | Source Code `shared actual Integer wholePart` The integral value of the number after truncation of the fractional part. For `Integral` numeric types, the integral value of a number is the number itself. Refines `Number.wholePart`
`zero` | Source Code `shared actual Boolean zero` Determine if the number is the additive identity. Refines `Integral.zero`

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`
Attributes inherited from: `Binary<Other>` `not`
Attributes inherited from: `Enumerable<Other>` `predecessor`, `successor`
Attributes inherited from: `Integral<Other>` `unit`, `zero`
Attributes inherited from: `Invertible<Other>` `negated`
Attributes inherited from: `Number<Other>` `absolute`, `fractionalPart`, `magnitude`, `negative`, `positive`, `sign`, `wholePart`
Attributes inherited from: `Ordinal<Other>` `predecessor`, `successor`

Methods
`and` | Source Code `shared actual Integer and(Integer other)` Performs a logical AND operation. Refines `Binary.and`
`clear` | Source Code `shared actual Integer clear(Integer index)` If the `index` is for an addressable bit, an instance with the same addressable bits as this instance, but with that bit cleared. Otherwise an instance with the same addressable bits as this instance. Refines `Binary.clear`
`compare` | Source Code `shared actual Comparison compare(Integer other)` Compares this value with the given value. Implementations must respect the constraints that: `x==y` if and only if `x<=>y == equal` (consistency with `equals()`), if `x>y` then `y<x` (symmetry), and if `x>y` and `y>z` then `x>z` (transitivity). Refines `Comparable.compare`
`divided` | Source Code `shared 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 `0`, the additive identity, the behavior depends on the numeric type: For some numeric types, including `Integer`, division by `0` results in an exception. For others, including `Float`, it results in a special value of the type, for example, `infinity`. Refines `Numeric.divided`
`divides` | Source Code `shared actual Boolean divides(Integer other)` Determine if this number is a factor of the given number. Refines `Integral.divides`
`equals` | Source Code `shared actual Boolean equals(Object that)` Determines if the given object is equal to this `Integer`, that is, if: the given object is an `Integer` representing the same whole number. Or if: the given object is a `Float`, its value is neither `Float.undefined`, nor `infinity`, the fractional part of its value equals `0.0`, and the integer part part of its value equals this integer, and this integer is between -253 and 253 (exclusive). Refines `Object.equals`
`flip` | Source Code `shared actual Integer flip(Integer index)` If the `index` is for an addressable bit, an instance with the same addressable bits as this instance, but with that bit flipped. Otherwise an instance with the same addressable bits as this instance. Refines `Binary.flip`
`get` | Source Code `shared actual Boolean get(Integer index)` If the `index` is for an addressable bit, the value of that bit. Otherwise false. Refines `Binary.get`
`largerThan` | Source Code `shared actual Boolean largerThan(Integer other)` Determines if this value is strictly larger than the given value. Refines `Comparable.largerThan`
`leftLogicalShift` | Source Code `shared actual Integer leftLogicalShift(Integer shift)` If shift is in the range of addressable bits (`0..runtime.integerAddressableSize-1`), shift the addressable bits to the left by `shift` positions. Otherwise shift the addressable bits to the left by `(bits + (shift % bits)) % bits` where `bits=runtime.integerAddressableSize`. Refines `Binary.leftLogicalShift`
`minus` | Source Code `shared actual Integer minus(Integer other)` The difference between this number and the given number. Must produce the value `x + -y`. Refines `Invertible.minus`
`modulo` | Source Code `shared actual Integer modulo(Integer modulus)` The modulo, after dividing this number by the given number. This differs from `Integral.remainder()` in that the result is always positive. Refines `Integral.modulo`
`neighbour` | Source Code `shared actual Integer neighbour(Integer offset)` The indirect successor or predecessor at the given `offset`, where: `x.neighbour(0) == x`, `x.neighbour(i+1) == x.neighbour(i).successor`, and `x.neighbour(i-1) == x.neighbour(i).predecessor`. Refines `Enumerable.neighbour`
`notLargerThan` | Source Code `shared actual Boolean notLargerThan(Integer other)` Determines if this value is smaller than or equal to the given value. Refines `Comparable.notLargerThan`
`notSmallerThan` | Source Code `shared actual Boolean notSmallerThan(Integer other)` Determines if this value is larger than or equal to the given value. Refines `Comparable.notSmallerThan`
`offset` | Source Code `shared actual Integer offset(Integer other)` Compute the offset from the given value, where: `x.offset(x) == 0`, and `x.successor.offset(x) == 1` if `x!=x.successor`. Refines `Enumerable.offset`
`offsetSign` | Source Code `shared actual Integer offsetSign(Integer other)` The sign of the offset from the given value. Refines `Enumerable.offsetSign`
`or` | Source Code `shared actual Integer or(Integer other)` Performs a logical inclusive OR operation. Refines `Binary.or`
`plus` | Source Code `shared 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 Code `shared actual Integer plusInteger(Integer integer)` The result of adding this number to the given `Integer`. Refines `Number.plusInteger`
`power` | Source Code `shared actual Integer power(Integer other)` The result of raising this number to the given non-negative integer power, where `0^0` evaluates to `1`. Throws `AssertionError` if the given power is negative Refines `Exponentiable.power`
`powerOfInteger` | Source Code `shared actual Integer powerOfInteger(Integer integer)` The result of raising this number to the given non-negative integer power, where `0^0` evaluates to `1`. Throws `AssertionError` if the given power is negative Refines `Number.powerOfInteger`
`remainder` | Source Code `shared actual Integer remainder(Integer other)` The remainder, after dividing this number by the given number. Refines `Integral.remainder`
`rightArithmeticShift` | Source Code `shared actual Integer rightArithmeticShift(Integer shift)` If shift is in the range of addressable bits (`0..runtime.integerAddressableSize-1`), shift the addressable bits to the right by `shift` positions, with sign extension. Otherwise shift the addressable bits to the right by `(bits + (shift % bits)) % bits` where `bits=runtime.integerAddressableSize`. Refines `Binary.rightArithmeticShift`
`rightLogicalShift` | Source Code `shared actual Integer rightLogicalShift(Integer shift)` If shift is in the range of addressable bits (`0..runtime.integerAddressableSize-1`), shift the addressable bits to the right by `shift` positions, with zero extension. Otherwise shift the addressable bits to the right by `(bits + (shift % bits)) % bits` where `bits=runtime.integerAddressableSize`. Refines `Binary.rightLogicalShift`
`set` | Source Code `shared actual Integer set(Integer index, Boolean bit)` If the `index` is for an addressable bit, an instance with the same addressable bits as this instance, but with that bit set to `bit`. Otherwise an instance with the same addressable bits as this instance. Refines `Binary.set`
`smallerThan` | Source Code `shared actual Boolean smallerThan(Integer other)` Determines if this value is strictly smaller than the given value. Refines `Comparable.smallerThan`
`times` | Source Code `shared actual Integer times(Integer other)` The product of this number and the given number. Refines `Numeric.times`
`timesInteger` | Source Code `shared actual Integer timesInteger(Integer integer)` The result of multiplying this number by the given `Integer`. Refines `Number.timesInteger`
`xor` | Source Code `shared actual Integer xor(Integer other)` Performs a logical exclusive OR operation. Refines `Binary.xor`

Inherited Methods
Methods inherited from: `Object` `equals()`
Methods inherited from: `Binary<Other>` `and()`, `clear()`, `flip()`, `get()`, `leftLogicalShift()`, `or()`, `rightArithmeticShift()`, `rightLogicalShift()`, `set()`, `xor()`
Methods inherited from: `Comparable<Other>` `compare()`, `largerThan()`, `notLargerThan()`, `notSmallerThan()`, `smallerThan()`
Methods inherited from: `Enumerable<Other>` `neighbour()`, `offset()`, `offsetSign()`
Methods inherited from: `Exponentiable<This,Other>` `power()`
Methods inherited from: `Integral<Other>` `divides()`, `modulo()`, `remainder()`
Methods inherited from: `Invertible<Other>` `minus()`
Methods inherited from: `Number<Other>` `plusInteger()`, `powerOfInteger()`, `timesInteger()`
Methods inherited from: `Numeric<Other>` `divided()`, `times()`
Methods inherited from: `Summable<Other>` `plus()`