function | since v1.11.50 | Edit |
(multiply-exact x y)
Returns the product of x and y, throws ArithmeticException on overflow.
(defn ^number multiply-exact
{:added "1.11.10"}
[x y]
(let [r (* x y)]
(if (or (> r js/Number.MAX_SAFE_INTEGER) (< r js/Number.MIN_SAFE_INTEGER))
(throw (ex-info "Integer overflow" {:fn "multiply-exact"}))
r)))