Ahem, that was not the OP ... and by rounding, I meant that one version (by Monk::Thomas) processed 3.14159 as 3, and one version (by 1nickt) processed 3.14159 as 4.
AFAIK -- doesn't round to a whole number ...
[08:19][nick:~]$ perl -e '$foo=$ARGV[0];$foo--;print "$foo\n";' 3.1415
+9
2.14159
... and anyway, the other version without the decrementation rounded _up_ from 3.14159 to 4, which is what seems stranger.
I suppose it has to do with the difference between for(my $i = 0; $i < $n; $i++) and for my $i (0..$n) { ... but I can't see it from here. Good example of why you should examine and test everything, I guess.
Remember: Ne dederis in spiritu molere illegitimi!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.