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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|