Rebol 程式設計/mod
外觀
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]
]