whats a good way to make sure a numeric (long) doe...
# announcements
r
whats a good way to make sure a numeric (long) doesn’t overflow? how about
val number = Math.max(x, x + y)
m
If you're on the JVM, you can use
Math.addExact(x, y)
which will throw an
ArithmeticException
if it overflows.
j
Or you could use java.math.BigInteger if that's useful for you
r
thanks for the suggestion guys.