Interesting results. It appears that it uses a float value (something like 123456.779999999) for the comparison but then any function rounds to two decimal places. Very strange.
I reported problems like this to Macromedia/Adobe for CF6. They said they updated the math functions in CF7 to better deal with decimals. From: [email protected] [mailto:[email protected]] On Behalf Of Will Barnes Sent: Friday, May 29, 2009 11:01 AM To: [email protected] Subject: [houcfug] Re: decimal math issues This is really weird. Simply plugging the two values into variables did not fix the issue with "IS" or "EQ". It seems that CF has extra data tied to summation and applying any basic function to the result will remove it. I got it working simply wrapping the variables with the trim function, even though both their lengths were 9. Very strange. Thanks, Will <cfset var1 = 107407.40+12345.68+3703.70> <cfset var2 = 123456.78> <cfif var1 IS var2>EQUAL<cfelse>NOT EQUAL</cfif> //NEQ <cfif var1 EQ var2>EQUAL<cfelse>NOT EQUAL</cfif> //NEQ #len(var1)# = #len(var2)#? // 9 = 9? #isNumeric(var1)# = #isNumeric(var2)#? // YES = YES? <cfif trim(var1) EQ trim(var2)>EQUAL<cfelse>NOT EQUAL</cfif> // EQUAL, this works On Fri, May 29, 2009 at 10:47 AM, Kier Simmons <[email protected]> wrote: I've duplicated his problem and tried all the various symantic changes. It is still there. I'm thinking it is in how the variant is defined. I'm going to try predefining the variables used first. Kier Simmons Analyst/Programmer <http://www.giveblood.org/> Phone: 713-791-6619 Toll Free: 1-888-482-5663 Fax: 713-791-6681 www.giveblood.org P Please consider the environment before printing this e-mail. The information contained in this message and any attachments is intended only for the use of the individual or entity to which it is addressed, and may contain information that is PRIVILEGED, CONFIDENTIAL, and exempt from disclosure under applicable law. If you are not the intended recipient, you are prohibited from copying, distributing, or using the information. Please contact the sender immediately by return e-mail and delete the original message from your system. ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Angeli Wahlstedt Sent: Friday, May 29, 2009 10:46 AM To: [email protected] Subject: [houcfug] Re: decimal math issues I saw that you were using 'IS"...have you tried "EQ"? Angeli Wahlstedt, IdeaSculpt LLC From: [email protected] [mailto:[email protected]] On Behalf Of Brett Roderick Sent: Friday, May 29, 2009 10:38 AM To: [email protected] Subject: [houcfug] decimal math issues I seem to run into ColdFusion math problems with decimal numbers from time to time. For example, I would expect the following to return EQUAL but instead it returns NOT EQUAL (on CF 8.0.1): <cfif 107407.40+12345.68+3703.70 IS 123456.78>EQUAL<cfelse>NOT EQUAL</cfif> I've fixed problems like this in the past with this: round(x*100)/100 I don't have confidence that will always work. Is there a better way to deal with this? I'm not looking forward to putting something like that in everywhere we do any computations with decimal numbers. Thanks, Brett The information contained in this message and any attachments is intended only for the use of the individual or entity to which it is addressed, and may contain information that is PRIVILEGED, CONFIDENTIAL, and exempt from disclosure under applicable law. If you are not the intended recipient, you are prohibited from copying, distributing, or using the information. Please contact the sender immediately by return e-mail and delete the original message from your system. ________________________________ This e-mail message and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any review, dissemination, or copying of this message and its attachments or the information contained herein is prohibited. If you have received this message in error, please notify the sender by return e-mail and delete this e-mail message from your computer. Thank you. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Houston ColdFusion Users' Group" discussion list. To unsubscribe, send email to [email protected] For more options, visit http://groups.google.com/group/houcfug?hl=en -~----------~----~----~----~------~----~------~--~---
<<inline: image001.gif>>
