Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Modulo of fraction?

by fglock (Vicar)
on Jun 27, 2005 at 19:24 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found