The output was the intuitive ("nice") version
Did you look at the intermediate values ? (That's what your original complainants were doing.)
C:\_32\pscrpt>perl -le "print $];"
5.024000
C:\_32\pscrpt>perl -V:archname
archname='MSWin32-x86-multi-thread-64int';
C:\_32\pscrpt>perl -V:nvtype
nvtype='double';
C:\_32\pscrpt>type try.pl
use warnings;
use strict;
my $x = 0;
for( 1..100 ) {
$x += 0.01;
print "$x\n" if length $x > 4;
}
C:\_32\pscrpt>perl try.pl
0.810000000000001
0.820000000000001
0.830000000000001
0.840000000000001
0.850000000000001
0.860000000000001
0.870000000000001
0.880000000000001
0.890000000000001
0.900000000000001
0.910000000000001
0.920000000000001
0.930000000000001
0.940000000000001
0.950000000000001
0.960000000000001
0.970000000000001
0.980000000000001
0.990000000000001
C:\_32\pscrpt>
Those are actually correct values (rounded to 15 decimal digits of precision) for a perl whose nvtype is an 8-byte double.
And it's also to be expected (given perl's current practice) that the next (and last) value to be calculated is printed as "1" - because 1.0000000000000007 rounded to 15 decimal digits of precision is exactly that.
Cheers,
Rob
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.