ceylon.language.Exponentiable.ceylon Maven / Gradle / Ivy
"Abstraction of [[numeric types|Numeric]] that may be raised
to a power using the _exponentiation_ operator `x ^ n`
which accepts an instance of `Exponentiable` as its first
operand, and an exponent as its second operand.
function exp(Float x) => e^x;
The exponentiation operation should obey the usual index
laws, including:
- `x^0 == 1`
- `x^1 == x`
- `x^(-1) == 1/x`
- `x^(m+n) == x^m * x^n`
- `x^(m-n) == x^m / x^n`
- `x^(m*n) == (x^m)^n`
- `(x*y)^n == x^n * y^n`
where `0` is the additive identity, and `1` is the
multiplicative identity.
Note that in general, the type of the exponent may be
different to the numeric type which is exponentiated. For
example, a `Rational` number class might be a subtype of
`Exponentiable`, thus accepting only
whole-number exponents."
see (`class Integer`, `class Float`)
tagged("Numbers")
shared interface Exponentiable of This
satisfies Numeric
given This satisfies Exponentiable
given Other satisfies Numeric {
"The result of raising this number to the given power."
shared formal This power(Other other);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy