Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

The "%" operator and its documentation.

by syphilis (Bishop)
on Jun 14, 2021 at 01:40 UTC ( #11133829=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    C:\_32>perl -wle "$m = (2**113) - 1; $n = 2; print $m % $n;"
    0
    
  2. or download this
    C:\_32>perl -MPOSIX -wle "$m = (2**113) - 1; $n = 2; print fmod($m, $n
    +);"
    1
    
  3. or download this
    Binary "%" is the modulo operator, which computes the division remaind
    +er
    of its first argument with respect to its second argument. Given integ
    +er
    ...
    Note that when "use integer" is in scope, "%" gives you direct access 
    +to
    the modulo operator as implemented by your C compiler. This operator i
    +s
    not as well defined for negative operands, but it will execute faster.
    
  4. or download this
    If $n is positive, then "$m % $n" is $m minus the largest multiple of 
    +$n less than or equal to $m.
    ....
    ...
    $n (that is "abs($n)") is less than "(UV_MAX + 1)", only the integer
    portion of $m and $n will be used in the operation (Note: here "UV_MAX
    +"
    means the maximum of the unsigned integer type)
    
  5. or download this
    C:\_32>perl -wle "$r = 10384593717069655257060992658440191.0 - (519229
    +6858534827628530496329220095.0 * 2); print $r;"
    1
    
  6. or download this
    C:\_32>perl -wle "$m = (2**113) - 1; $n = 2; print $m % $n;"
    0
    
    C:\_32>perl -MPOSIX -wle "$m = (2**113) - 1; $n = 2; print fmod($m, $n
    +);"
    1
    
  7. or download this
    C:\>perl -wle "$m = (2**64) - 1; $n = 2; print $m % $n;"
    0
    
    C:\>perl -MPOSIX -wle "$m = (2**64) - 1; $n = 2; print fmod($m, $n);"
    1
    
  8. or download this
    C:\_32>perl -wle "$m = (2**53) - 1; $n = 2; print $m % $n;"
    1
    
    C:\_32>perl -MPOSIX -wle "$m = (2**53) - 1; $n = 2; print fmod($m, $n)
    +;"
    1
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11133829]
Approved by GrandFather
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-09-29 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?