Re: Illegal Modulus zeroby Zaxo (Archbishop)
|on May 21, 2005 at 01:43 UTC||Need Help??|
You've found your error but, IMO, "Illegal modulus zero . . ." shouldn't be an error. A number mod zero is perfectly well-defined.
The trick is that '%' doesn't need to be defined in terms of division. It's better defined as,
$z == $x % $yIf $y is zero, $x % 0 == $x. If $y is one, $z is the fractional part of $x.
This definition is good for any additive group, since multiplication by an integer has a natural definition there even if multiplication of group elements doesn't exist. That would permit useful overloading of '%' for vectors or other objects with no useful group multiplication.