unchecked-multiply

clojure.core

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

1 Example top

  • ;; demonstrate the the unchecked-multiply function cannot calculate
    ;; 1 trillion * 10 without throwing an exception
    
    user=> (def thous 1000)
    #'user/thous
    user=> (def trill (* thous thous thous thous))
    #'user/trill
    user=> (unchecked-multiply trill 10)
    java.lang.IllegalArgumentException: No matching method found: unchecked_multiply
     (NO_SOURCE_FILE:0)
    user=> (* trill 10)
    10000000000000
    user=>
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:1161 top

(defn unchecked-multiply
  "Returns the product of x and y, both 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:
Used in 0 other vars

Comments top

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