You're viewing version 1.2.0 of rem. The latest stable version of Clojure Core is 1.3.0.
1.2.0 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:1010 top

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

Comments top

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