Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: limit of for loop!!

by flexvault (Monsignor)
on Jan 02, 2012 at 17:11 UTC ( [id://945934]=note: print w/replies, xml ) Need Help??


in reply to limit of for loop!!

You could use 'sprintf' as part of the loop. Adds some time, but maintains your 3 digits of precision.

perl -e '$n=22.4; for(1..99) { $n = sprintf("%.3f", $n+0.001 ); } prin +t "Result: $n\n";'

Hint: Try to think of your numbers as '$n' or '$s' and not '$a'. You'll understand in the future.

Good Luck

"Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-16 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found