clojure中rem和mod的区别 详见clojure doc

看例子

01 user=> (mod 10 5)
02 0
03  
04 user=> (mod 10 6)
05 4
06  
07 user=> (mod 10 10)
08 0
09  
10 user=> (mod 10 -1)
11 0
12  
13 ;; 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.
14 ;; The largest integer multiple of 5 not greater than -2 is 5 * -1 = -5. The amount by which -2 exceeds -5 is 3.
15 ;;
16 user=> (mod -2  5)
17 3



01 ;; rem和mod通常用于求余数
02 ;; mod的结果不为负数    此处文档有误   当(mod 10 -3)时输出为 -2 

07 user=> (mod -10 3)
08 2
09 ;; -10 mod 3 (-12 mod 3 )
10ss user=> (rem -10 3)
11 -1


你可能感兴趣的:(clojure中rem和mod的区别 详见clojure doc)