You're getting some floating point rounding issues. The number -1.06581410364E-014 can be written as -0.000000000000010658141036. This is below the threshold of your floating point arithmetic to handle. You should round it off to the 12th or 13th decimal point and accept it as zero.
Based on your inputs (2 decimal places), it doesn't look like you will start a hurricane with your butterfly wings. (Sorry if that's a too obscure chaos reference). ------------------------------------ Gerry Gurevich Application Development NIEHS ITSS Contractor Lockheed Martin Information Technology 919-361-5444 ext 311 ________________________________ From: Howard Fore [mailto:[EMAIL PROTECTED] Sent: Friday, December 28, 2007 11:20 AM To: [email protected] Subject: [ACFUG Discuss] Negative plus positive equals less than zero? Hey, Can someone confirm this seemingly odd behavior? If I execute the following code: <cfscript> total = 0; numberList = "62355.57,-62355.57,-333.01,261.09 ,17.98,35.96,17.98"; for (i = 1;i lte listLen(numberList);i = i + 1) { writeOutput("#total# + #ListGetAt(numberList,i)# = "); total = total + ListGetAt(numberList,i); writeOutput("#total#<br>"); } writeOutput('numberFormat(total,"999,999,999.99") = ' & numberFormat(total,"999,999,999.99")); </cfscript> I get the following output: 0 + 62355.57 = 62355.57 62355.57 + -62355.57 = 0 0 + -333.01 = -333.01 -333.01 + 261.09 = -71.92 -71.92 + 17.98 = -53.94 -53.94 + 35.96 = -17.98 -17.98 + 17.98 = -1.06581410364E-014 numberFormat(total,"999,999, 999.99") = -0.00 I've tried using javacasts to make sure that there wasn't some odd string to number conversion thing going on too and still got the same result. Any ideas? -- Howard Fore, [EMAIL PROTECTED] "Whether you believe you can do a thing or not, you are right." -- Henry Ford ------------------------------------------------------------- Annual Sponsor - Figleaf Software <http://www.figleaf.com> To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by FusionLink <http://www.fusionlink.com> ------------------------------------------------------------- ------------------------------------------------------------- Annual Sponsor FigLeaf Software - http://www.figleaf.com To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com -------------------------------------------------------------
