Numbers

Abstraction of numeric types with the usual binary operations:

- addition, `x + y`,
- subtraction, `x - y`,
- multiplication, `x * y`, and
- division, `x / y`, along with
- additive inverse `-x`.

A concrete class which implements this interface should be a mathematical ring. That is:

- both addition, `+`, and multiplication, `*`, should be associative and commutative,
- there should be additive and multiplicative identities, denoted `0` and `1` respectively, satisfying `x+0 == x` and `x*1 == x`,
- every instance `x` should have an additive inverse `-x`, satisfying `x + -x == 0`, and
- multiplication should distribute over addition, satisfying `x*(y+z) == x*y + x*z`.

It is preferred, but not required, that the class be a mathematical field. That is, in addition to the above:

- every instance `x` such that `x!=0` should have a multiplicative inverse `1/x`, satisfying `x * 1/x == 1`.

For numeric types which are not fields, for example, `Integer`, there is still a division operation, which is understood to produce a remainder. The division operation should satisfy:

- `x*y / y == x`

for any instance `y` other than `0`.

For numeric types which are fields, division never produces a remainder, and division should additionally satisfy:

- `x/y * y == x`

for any instance `y` other than `0`.

Some numeric types, for example complex numbers, do not have a total order. Numeric types with a total order also satisfy `Number`.

By: Gavin
See also `Number`

no type hierarchy

- `Numeric`
  - `Invertible`
    - `Summable`

- `Numeric` of
  - `Exponentiable`
    - `Float`
    - `Integer`
  - `Number`
    - `Float`
    - `Integral`
      - `Integer`

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`
Attributes inherited from: `Invertible<Other>` `negated`

Methods
`divided` | Source Code `shared formal Other divided(Other other)` The quotient obtained by dividing this number by the given number. For integral numeric types, this operation rounds toward `0`, the additive identity, and results in a remainder. When the given divisor is exactly `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`. See also `Integral.remainder()`, `infinity`
`times` | Source Code `shared formal Other times(Other other)` The product of this number and the given number.

Inherited Methods
Methods inherited from: `Object` `equals()`
Methods inherited from: `Invertible<Other>` `minus()`
Methods inherited from: `Summable<Other>` `plus()`