addExact(x: Long, y: Long)
is a function in the math
package in Scala that calculates the sum of its arguments.
def addExact(x: Long, y: Long):Long
The function takes in two parameters, x
and y
. Both parameters are of type Long
.
The function returns the sum of x
and y
. The value is of type Long
.
The function throws
ArithmeticException
ifLong
is overflowed by addingx
andy
.
object MainObject { def main(args: Array[String]) { var x : Long = 220; var y : Long = 23; println("Math.addExact(x, y) = "+ Math.addExact(x, y)); } }
RELATED TAGS
CONTRIBUTOR
View all Courses