Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Modulo operation to return quotient and remainder

by dasgar (Curate)
on Jul 11, 2012 at 19:56 UTC ( #981243=note: print w/replies, xml ) Need Help??

in reply to Modulo operation to return quotient and remainder

As pointed out, it's not difficult to do it with just a few lines of code. If you wanted to, you could also just create a subroutine like the untested code below:

use strict; use warnings; sub modulo { my $number = shift; my $divisor = shift; my $remainder = $number % $divisor; my $quotient = ($number - $remainder) / $divisor; return ($remainder, $quotient); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981243]
[msh210]: *finally* tracked down the source of nonsensical results: I had sum0 (@ary / $foo) instead of (sum0 @ary) / $foo

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-01-17 17:16 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (158 votes). Check out past polls.