cgoodman
Programmer
- Dec 29, 2008
- 7
Hey guys,
I ran across something really odd today. I'm summing columns in a flat file, and then running an equivalence check against the cooresponding summed columns.
This is my code for the summing of the columns:
CFIELD = 129, CFIELD2 = 128....
There is a problem with SUM2. The output from the print(SUM2) statement is as follows:
-17106.00000000000000000000000000000000000000000000000000
-34212.00000000000000000000000000000000000000000000000000
-356046.00000000000000000000000000000000000000000000000000
-407297.00000000000000000000000000000000000000000000000000
-712275.00000000000000000000000000000000000000000000000000
-944788.00000000010000000000000000000000000000000000000000
Notice that there is a 1 in the final sum, when there are no "hanging 1's" in any of the other sums. (I changed the variable OFMT to "%.50f" to check the actual value of the number)
The rest of the SUM's add as expected.
Any ideas where the "hanging 1" came from?
I ran across something really odd today. I'm summing columns in a flat file, and then running an equivalence check against the cooresponding summed columns.
This is my code for the summing of the columns:
Code:
SUM1 += ($CFIELD)*100;
SUM2 += ($CFIELD2)*100;
print(SUM2);
SUM3 += ($CFIELD3)*100;
SUM4 += ($CFIELD4)*100;
SUM5 += ($CFIELD5)*100;
SUM6 += ($CFIELD6)*100;
CFIELD = 129, CFIELD2 = 128....
There is a problem with SUM2. The output from the print(SUM2) statement is as follows:
-17106.00000000000000000000000000000000000000000000000000
-34212.00000000000000000000000000000000000000000000000000
-356046.00000000000000000000000000000000000000000000000000
-407297.00000000000000000000000000000000000000000000000000
-712275.00000000000000000000000000000000000000000000000000
-944788.00000000010000000000000000000000000000000000000000
Notice that there is a 1 in the final sum, when there are no "hanging 1's" in any of the other sums. (I changed the variable OFMT to "%.50f" to check the actual value of the number)
The rest of the SUM's add as expected.
Any ideas where the "hanging 1" came from?