Hi, Ladislav,
One other possibility (that isn't vulnerable to negatives divisors, as
was the one I posted within the past couple of days) is:
mod: func [
"computes true (natural) modulus"
a [integer!] "dividend"
b [integer!] "divisor"
][
a // b + (b: abs b) // b
]
This is certainly no faster than the one below, but is at least "all
arithmetic"...
-jn-
[EMAIL PROTECTED] wrote:
>
> Hi,
>
> does anybody know a simpler way how to compute:
>
> mod: func [
> {compute a non-negative remainder}
> a [number!]
> b [number!]
> /local r
> ] [
> either negative? r: a // b [
> r + abs b
> ] [r]
> ]
>
> Regards
> Ladislav