What is multiplyExact(x: Int, y: Int) in Scala?

multiplyExact(x: Int, y: Int) is a function in the math package of Scala. The function returns the product of the numbers passed in as arguments.

Syntax

def multiplyExact(x: Int, y: Int) : Int

Parameters

The function takes two parameters: 1.x

2.y

The parameters are of type Int.

Return value

The function returns xx*yy.

The function throws ArithmeticException if Int is overflowed by the return value.

Code

object MainObject {
def main(args: Array[String]) {
var x : Int = 31;
var y : Int = 11;
println("Math.multiplyExact(x, y) = " + Math.multiplyExact(x, y));
}
}

Free Resources