Note: information on this page refers to Ceylon 1.0, not to the current release.
%
(remainder) operator
The binary, left-associative infix %
operator is used to get the remainder of an
integer division.
Usage
Integer two = 5 % 3;
Description
Definition
The %
operator is defined as follows:
lhs.remainder(rhs);
See the language specification for more details.
Polymorphism
The %
operator is polymorphic.
The meaning of %
depends on the
Integral
interface.
Type
The result type of the %
operator is the same as the type of its right hand operand.
Meaning of remainder for built-in types
For the built-in numeric type Integer
,
%
computes normal mathematical remainder.
Since the other built-in numeric types do not satisfy Integral
, the
remainder operator cannot be used on them.
See also
- API documentation for
Integral
- arithmetic operators in the language specification
- operator precedence in the language specification
- Operator polymorphism and Numeric operator semantics in the Tour of Ceylon