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 reply to Re: A better mod (%) operator?
by fglock
in thread A better mod (%) operator?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |