Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Modulo operation to return quotient and remainder

by moritz (Cardinal)
on Jul 12, 2012 at 11:54 UTC ( #981384=note: print w/ replies, xml ) Need Help??


in reply to Modulo operation to return quotient and remainder

While many modern CPU instruction sets support getting quotient and remainder in a single operation, nearly no high-level programming languages support it. Not even C (unless via embedded assembler).

In Perl, the overhead of a single subroutine call is probably much bigger than simply performing two separate operations, so from a performance point of view, you shouldn't bother.

If you are after convenience, it's easy enough to write a subroutine yourself that does it.


Comment on Re: Modulo operation to return quotient and remainder

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981384]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2015-07-06 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (84 votes), past polls