angerangel edited this page Jan 4, 2013 · 1 revision

USAGE

   MODULO a b

DESCRIPTION

Wrapper for MOD that handles errors like REMAINDER. Negligible values (compared to A and B) are rounded to zero.

MODULO is a function value.

ARGUMENTS

  • a (number! money! time!)
  • b -- Absolute value will be used (number! money! time!)

#SOURCE

modulo: make function! [  [
    {Wrapper for MOD that handles errors like REMAINDER. Negligible values (compared to A and B) are rounded to zero.}
    a [number! money! time!]
    b [number! money! time!] "Absolute value will be used"
    /local r
][
    any [number? a b: make a b]
    r: mod a abs b
    either any [a - r = a r + b = b] [make r 0] [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.