Back
negate-exact (clj)
(source)function
(negate-exact a)
Returns the negation of a, throws ArithmeticException on overflow.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#negateExact-long-
Examples
clojure
(ns clojure.test-clojure.math
(:require
[clojure.test :refer :all]
[clojure.math :as m]))
(deftest test-negate-exact
(is (= (inc Long/MIN_VALUE) (m/negate-exact Long/MAX_VALUE)))
(try
(m/negate-exact Long/MIN_VALUE)
(is false)
(catch ArithmeticException _
(is true))))