Hello chiel,
You should definitely read the pages LanX linked to. The second especially is required reading for anyone who wants to write a computer program.
However, I did want to point out you can use the bignum pragma to get Perl 5 to do what you want:
$ perl -e '
use warnings;
use bignum;
my $size = 0.01;
my $step_size = 0.01;
while($size < 5){
$size = $size + $step_size;
print $size."\n";
}
print "FINAL: ".$size."\n";'
...
4.94
4.95
4.96
4.97
4.98
4.99
5
FINAL: 5
Best,
Jim
-
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.
|