Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: sprintf rounding convention

by kennethk (Abbot)
on Oct 30, 2009 at 22:24 UTC ( [id://804228]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -v
    
    ...
    $ perl -e 'printf "%.2f\n%.2f\n", 0.335, 1.335;'
    0.34
    1.33
    
  2. or download this
    
    C:\>perl -v
    ...
    C:\>perl -e "printf qq{%.2f\n%.2f\n}, 0.335, 1.335;"
    0.34
    1.34
    
  3. or download this
    $ perl -v
    
    This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi
    ...
    C:\>perl -e "printf qq{%.40f\n%.40f\n}, 0.335, 1.335;"
    0.3350000000000000200000000000000000000000
    1.3350000000000000000000000000000000000000
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-06-13 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.