Rebol 编程/mod
外观
< Rebol 编程
MOD a b
计算 A 除以 B 的非负余数。
MOD 是一个函数值。
- a -- (类型:数字货币时间)
- b -- 必须是非零值。(类型:数字货币时间)
- 捕获
mod: func [
"Compute a nonnegative remainder of A divided by B."
[catch]
a [number! money! time!]
b [number! money! time!] "Must be nonzero."
/local r
][
all [negative? r: a // b r: r + b]
a: abs a
either all [a + r = (a + b) positive? r + r - b] [r - b] [r]
]