You're viewing version 1.2.0 of unchecked-multiply. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

unchecked-multiply

clojure.core

  • (unchecked-multiply x y)
Returns the product of x and y, both int or long.
Note - uses a primitive operator subject to overflow.

1 Example top

  • ;; the unchecked-multiply function silently overflows
    
    user=> (* 1000000000000 10)
    10000000000000
    user=> (unchecked-multiply 1000000000000 10)
    10000000000000
    
    user=> (* 3037000500 3037000500)
    ArithmeticException integer overflow  clojure.lang.Numbers.throwIntOverflow (Numbers.java:1424)
    user=> (unchecked-multiply 3037000500 3037000500)
    -9223372036709301616
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:969 top

(defn unchecked-multiply
  "Returns the product of x and y, both int or long.
  Note - uses a primitive operator subject to overflow."
  {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_multiply ~x ~y)))
   :added "1.0"}
  [x y] (. clojure.lang.Numbers (unchecked_multiply x y)))
Vars in clojure.core/unchecked-multiply: defn
Used in 0 other vars

Comments top

No comments for unchecked-multiply. Log in to add a comment.