跳轉到內容

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]
]
華夏公益教科書