Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

(s)printf and rounding woes

by Not_a_Number (Prior)
on Nov 04, 2003 at 22:25 UTC ( [id://304559]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    for my $num ( 0 .. 101 ) {
       $num += 0.005;
       printf "%.2f\n", $num;
    }
    
  2. or download this
    0.01
    1.00
    2.00
    ...
    ..
    8.01
    ..
    
  3. or download this
    for my $num ( 0 .. 101 ) {
       $num += 0.0005;
       my $result = sprintf "%.3f", $num;
       print "$result\n";
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-19 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found