forked from rebol/rebol
-
Notifications
You must be signed in to change notification settings - Fork 2
angerangel edited this page Mar 19, 2013
·
1 revision
MOD a b
Compute a nonnegative remainder of A divided by B.
MOD is a function value.
- a (number! money! time!)
- b -- Must be nonzero. (number! money! time!)
#SOURCE
mod: make function! [ [
"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]
] ]