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.
    ;; but when dealing with negative num(ber), the difference 
    ;; between rem and mod becomes obvious
    
    ;; mod means Gaussian's mod. So remainder always
    ;; should be positive value.
    ;; Remainder is same with % operator in ANSI C
    
    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.