Back
multiply-exact (clj)
(source)function
(multiply-exact x y)
Returns the product of x and y, throws ArithmeticException on overflow.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#multiplyExact-long-long-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-multiply-exact
(try
(m/multiply-exact Long/MAX_VALUE 2)
(is false)
(catch ArithmeticException _
(is true))))