angerangel edited this page Jan 4, 2013 · 1 revision

USAGE

   MOD a b

DESCRIPTION

Compute a nonnegative remainder of A divided by B.

MOD is a function value.

ARGUMENTS

  • 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]
] ]
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.