Reading Time: < 1 minuteWe have following types of Arithmetic operators in Kotlin.
|Addition||+||a + b||a.plus(b)||Used for Addition|
|Subtraction||–||a – b||a.minus(b)||Used for Subtraction|
|Multiplication||*||a * b||a.times(b)||Used for multiplication|
|Division||/||a / b||a.div(b)||Used for division|
|Modulo||%||a % b||a.mod(b)||Used to get remainder of the division|
These operations are binary, wich means they operate with two operands.
The following code declares two integer variables and prints their sum using the + (addition) operators
The division (/) operator results in an integer, removing any remainder.
To get the remainder of the division, use the % (modulo) operator.
The modulo operator cannot be applied to floating-point numbers.
However the division operator works with floating-point values and results in a floating-point result.