Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Math::round not rounding correctly

by Laurent_R (Canon)
on Dec 23, 2014 at 22:46 UTC ( [id://1111249]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -e 'printf " %.1f => %.0f\n", $_, $_ for qw  / .5 1.5 2.5 3.5 4
    +.5 5.5 6.5 7.5 8.5 9.5/;'
     0.5 => 0
    ...
     7.5 => 8
     8.5 => 8
     9.5 => 10
    
  2. or download this
    $ perl -e 'printf " %.0f \n", 3461.5;'
     3462
    ...
    $  perl -e 'printf " %.0f \n", 3462.5;'
     3462
    
  3. or download this
    $ perl -e 'printf " %.0f \n", 3010*1.15,'
     3461
    
  4. or download this
    $ perl -e 'printf "%.15f \n",  3010*1.15,'
    3461.499999999999545
    
  5. or download this
    $ perl -e 'printf "%.19f \n",  1.15;'
    1.1499999999999999112
    
  6. or download this
    $ perl -e 'printf " %.0f \n", 301*11.5;'
     3462
    
  7. or download this
    $ perl -E 'say 301*11.5 - 3010*1.15;'
    4.54747350886464e-13
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found