(unchecked-negate x)
Returns the negation of x, a long. Note - uses a primitive operator subject to overflow.
;; *Almost* always the same as "-"
user=> (= (- 2) (unchecked-negate 2))
true
user=> (= (- (Long/MAX_VALUE)) (unchecked-negate (Long/MAX_VALUE)))
true
;; Except when it's not, because (- (Long/MIN_VALUE)) overflows:
user=> (= (- (Long/MIN_VALUE)) (unchecked-negate (Long/MIN_VALUE)))
ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1501)
;; Indeed:
user=> (unchecked-negate (Long/MIN_VALUE))
-9223372036854775808
;; Careful!
user=> (= (Long/MIN_VALUE) (unchecked-negate (Long/MIN_VALUE)))
true