I don't get it. It doesn't look like a logic issue, though.
issuing
:%s/0\.0/0./g while editing in vi, writing and executing yields:
#!/usr/bin/perl
use strict;
use warnings;
my $base = 0.425;
while ( my $line = <DATA>){
chomp $line;
my ($z,$c1,$c2,$c3,$c4) = split(/,/,$line);
print join("|",$z,$c1,$c2,$c3,$c4),"\n";
my $total = $c1+$c2+$c3;
print $c4 == ($total + $base) ? "True\n" : "False $c4 != ".($total+$
+base)."\n";
}
__DATA__
00501,0.000,0.425,0.025,0.875
00544,0.000,0.425,0.025,0.875
06390,0.000,0.425,0.025,0.875
with results:
00501|0.000|0.425|0.025|0.875
True
00544|0.000|0.425|0.025|0.875
True
06390|0.000|0.425|0.025|0.875
True
So making everything 10 times bigger yields expected results. Rounding error?
--Bob Niederman, http://bob-n.com
-
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.