Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Zero Padding to the Right of the Decimal

by Cody Pendant (Prior)
on Jan 15, 2004 at 20:40 UTC ( #321665=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Zero Padding to the Right of the Decimal
in thread Zero Padding to the Right of the Decimal

Just one more thing, how about this:

printf( "%3.2f\n" , ($i + 0.01) );

Instead of the two lines above?



($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print


Comment on Re: Re: Re: Zero Padding to the Right of the Decimal
Download Code
Re: Re: Re: Re: Zero Padding to the Right of the Decimal
by boo_radley (Parson) on Jan 15, 2004 at 20:54 UTC
    you'll never exit the loop that way, because you never modify $i.
    You could use +=, though :
    my $i=0; while ($i <=100){ printf("%3.2f\n",$i+=0.01); }

      This thread is probably already too deep for anyone to care, but if I were doing this, I would do so thusly:

          printf "%3.2f\n", $_/100 for 0 .. 100*100;
Re: Re: Re: Re: Zero Padding to the Right of the Decimal
by Not_a_Number (Parson) on Jan 15, 2004 at 20:59 UTC
        printf( "%3.2f\n" , ($i + 0.01)  );

    doesn't work.

    Change to:

        printf( "%3.2f\n" , ($i += 0.01)  );

    dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-07-30 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls