object OverflowCheck {
def multiplyWillOverflow(x: Long, y: Long): Boolean = {
if (x == 0) return false
if (y > Long.MaxValue / x) return true
if (y < Long.MinValue / x) return true
false
}
def main(args: Array[String]): Unit = {
var x: Long = 34
var y: Long = 14727836
println(if (multiplyWillOverflow(x, y)) "true" else "false")
x = 133883
y = 189993272783642L
println(if (multiplyWillOverflow(x, y)) "true" else "false")
}
}
/*
run:
false
true
*/