Comparing floating-point numbers cannot bedone with an equality operator as the binary representation of floating-pointnumbers may not be exact. One would almost always subtract one number from theother and then test that the difference was within some specified range.
For example
If (abs(result – expectedResult)< 0.0001)
Do something
Else …
Hope this helps
Howard
---
Howard Pell
Senior Technical Educator Liaison, SpecialProjects
Open Text Corporation
www.opentext.com
Office: (519) 888-7111 Ext. 2203
Mobile (519) 574-2248
From: eLinkDiscussion: LAPI Discussion [mailto:lapi@elinkkc.opentext.com] Sent: 2009-May-29 1:27 PMTo: eLink RecipientSubject: Comparison of realnumbers fails
Comparison of real numbers fails
Posted by welfar01user15 (Kudithipudi, Sravan) on 2009/05/29 13:26
I have two REAL fields debit w/ value of G1436908.22 credits w/ value of G1436908.22 The following code is entering IF block even though the values are same. Any thoughts //if(debits != totalcredit) OR if(debits NE totalcredit) @ @ echo('Debits and Credits are not equal. Please make corrections') @ @ return false end@ @ @ @ @ @ @ @