^ (power) operator
The right-associative, binary infix ^ operator is used to compute its left-hand
operand raised to the power of its right-hand operand.
Usage
Integer eight = 2 ^ 3;
Description
Definition
The ^ operator is defined as follows:
lhs.power(rhs);
See the language specification for more details.
Polymorphism
The ^ operator is polymorphic.
The meaning of ^ depends on the
Exponentiable interface.
Type
The result type of the ^ operator is the same as the type of the This type argument of its left hand
Exponentiable<This, Other> operand.
Meaning of power for built-in types
For the built-in numeric types Integer and
Float, ^
performs normal mathematical exponentiation, subject to the limitations
of the relevant type.
See also
- API documentation for
Exponentiable - arithmetic operators in the language specification
- operator precedence in the language specification
- Operator polymorphism and Numeric operator semantics in the Tour of Ceylon