您的位置:首页 > 其它

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

2014-07-09 15:09 1061 查看
看例子

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: