I appreciate the idea, but... still confused. I've changed the code to the following:
my $tolerance = 1.0e-16; # Change this value based on observation
if ($tolerance*abs($range_min + $change_min) < abs($range_min - $chang
+e_min)) {
print "$variable has different minimum value:\n";
print " Change list: $changes{$variable}{min} ($changes{$variable
+}{sheet})\n";
print " Range file : $range_file{$variable}{min} ($range_file{$va
+riable}{sheet})\n";
my $difference = $range_min - $change_min;
printf " Difference : %0.24f\n", $difference;
}
if ($tolerance*abs($range_max + $change_max) < abs($range_max - $chang
+e_max)) {
print "$variable has different maximum value:\n";
print " Change list: $changes{$variable}{max} ($changes{$variable
+}{sheet})\n";
print " Range file : $range_file{$variable}{max} ($range_file{$va
+riable}{sheet})\n";
my $difference = $range_min - $change_min;
printf " Difference : %0.24f\n", $difference;
}
Only difference to what you posted is the printf rather than print. And that was because the difference being shown with print was zero. This change in the code eliminated differences for four of the seven variables, but three remain:
variable_c has different maximum value:
Change list: 45142.388774415 (Intermediate Variables)
Range file : 45142.388774415 (Intermediate Variables)
Difference : -0.000000000000014210854715
variable_f has different maximum value:
Change list: 181.019658002611 (Intermediate Variables)
Range file : 181.019658002611 (Intermediate Variables)
Difference : 0.000000000000000000000000
variable_g has different maximum value:
Change list: 1.57615706403821 (Intermediate Variables)
Range file : 1.57615706403821 (Intermediate Variables)
Difference : 0.000000000000000000000000
Variable C makes some sort of sense. I mean, I'm still under the impression that if I assign 45142.388774415 directly to two different variables, they should both have the same floating point representation. But they don't, obviously.
But what the hork is up with the other two? It seems to me that if the tolerance is 1e-16, there should be some difference shown in 24 places in the floating point number.
-
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.