Author | Topic: Error in math sums | |
---|---|---|
Paulo Pinheiro | Error in math sums on Tue, 10 Mar 2009 17:07:45 +0000 Hello All, I know this is not a new problem, and probably not completly a Xbase++ problem, but i believe an effort should be done by Alaska in order to correct it. I include a small example (of a real problem) that doesn't work correctly. The goal is to check if a sum of values (aValues) is equal to a given total (nTotal). If we uncomment the line <nSum := Round( nSum, 2 )> this works. PROCEDURE Main() local nSum local aValues := { 2.02, 2.21, 1.31 } local nTotal := 5.54 nSum := 0.00 AEval( aValues, { |x| nSum += x } ) **** nSum := Round( nSum, 2 ) if nSum # nTotal ? "BAD", nSum, nTotal else ? "OK" endif Inkey(0) RETURN |