|
|
Axel Baune schrieb:
> I think you are wrong. As from my crypography course I know a definition
> for modulus, which also allows negative return values. The modulus function
In math, they usually call this "remainder", defined like
rem(a,b)=a-b*trunc(a/b).
The modulus is defined as Uwe wrote, i.e.
mod(a,b)=a-b*floor(a/b)
Compilers etc. just say
practicalmod(a,b)=a-b*int(a/b)
where int() is required to act like floor() on positive
arguments and left to the implementor for negative ones.
Ususally it behaves like trunc(), since this is what chips
do.
Ralf
Post a reply to this message
|
|