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