A symbol that instructs the compiler to perform specified mathematical or logical operations is known as an operator. Scala has a lot of built-in operators, and in this post, we’ll talk about Arithmetic Operators.
The supplied operands are added using the + (Plus) symbol.
To subtract the second operand from the first, use the – (Minus) symbol.
The specified operands are multiplied using the symbol * (Asterisk).
To divide the numerator by the de-numerator, use the symbol / (Slash).
% (Percentage) Symbol is used to find the remainder after division of one number by another.
Let’s see how it works.
Scala> 2.2 + 3.8
res0: Double = 6.0
Scala> 2 + 3
res1: Int = 5
Scala> 2.2 * 3.3
res2: Double = 7.26
res3: Double = 1.0999
res4: Int = 17
res5: Double = 1.5
Hope you find this article helpful.
Please subscribe for more interesting updates.