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
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.