Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 about the Monastery: (17)
As of 2014-09-23 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (224 votes), past polls