Arities ================================================== [num div] Docstring ================================================== Modulus of num and div. Truncates toward negative infinity.

Arities ================================================== [num div] Docstring ================================================== Modulus of num and div. Truncates toward negative infinity.

```
(defn mod
"Modulus of num and div. Truncates toward negative infinity."
{:added "1.0"
:static true}
[num div]
(let [m (rem num div)]
(if (or (zero? m) (= (pos? num) (pos? div)))
m
(+ m div))))
```

```
(mod 10 5)
;; => 0
(mod 10 6)
;; => 4
(mod 10 10)
;; => 0
(mod 10 -1)
;; => 0
;; The mod function is defined as the amount by which a number exceeds
;; the largest integer multiple of the divisor that is not greater
;; than that number. The largest integer multiple of 5 not greater
;; than -2 is 5 * -1 = -5. The amount by which -2 exceeds -5 is 3.
(mod -2 5)
;; => 3
```