Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Modulo of fraction?

by fglock (Vicar)
on Jun 27, 2005 at 19:24 UTC ( #470365=note: print w/ replies, xml ) Need Help??


in reply to Modulo of fraction?

You can rewrite the modulus function as:

sub my_mod { my ( $a, $b ) = @_; my $div = $a / $b; return $a - int( $div ) * $b; } print my_mod( 4, 1.5 ), "\n"; # 1 print my_mod( 4, 0.5 ), "\n"; # 0 print my_mod( 4, 0.7 ), "\n"; # 0.5


Comment on Re: Modulo of fraction?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-10-23 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls