1.3.0 permalink Arrow_down_16x16
  • (rem num div)
remainder of dividing numerator by denominator.

2 Examples top

  • user=> (rem 10 9)
    1
    user=> (rem 2 2)
    0
  • ;; rem and mod are commonly used to get the remainder.
    ;; mod means Gaussian mod, so the result is always
    ;; non-negative.  Don't confuse it with ANSI C's %
    ;; operator, which despite being although pronounced
    ;; 'mod' actually implements rem, i.e. -10 % 3 = -1.
    
    user=> (mod -10 3)
    2
    
    user=> (rem -10 3)
    -1
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:1204 top

(defn rem
  "remainder of dividing numerator by denominator."
  {:added "1.0"
   :static true
   :inline (fn [x y] `(. clojure.lang.Numbers (remainder ~x ~y)))}
  [num div]
    (. clojure.lang.Numbers (remainder num div)))
Vars in clojure.core/rem:
Used in 0 other vars

Comments top

No comments for rem. Log in to add a comment.