in reply to A better mod (%) operator?
This is something I used in the old times when multiplication was much faster than division:
sub divmod { use integer; my ($a, $b) = @_; my $tmp = $a / $b; ($tmp, $a - ($b * $tmp) ); } $a = 13; $b = 2; print divmod($a, $b);
This is much more interesting to do in assembler then in Perl (maybe Parrot?)
In Section
Meditations