DOCUMENT:Q189866 11-DEC-1999 [foxpro] TITLE :BUG: Incorrect Results When Comparing Large Numbers PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:5.0,5.0a,6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a, 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== When you compare two numbers for equality, you might receive an erroneous result when the resulting numbers are very large. NOTE: This behavior does not occur in Visual FoxPro 3.0x. RESOLUTION ========== Use the ROUND() function when checking the equality of very large floating- point numbers. For example, the following line of code produces the correct result: ?ROUND(1+(1048575+(i/1000)),5)=1048576.001 STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- Type the following commands in the Command window: SET DECIMAL to 5 i=1 ?(1+(1048575+(i/1000)))=1048576.001 ?1+(1048575+(1/1000))=1048576.001 Notice that the first calculation, using the variable i, evaluates as false while the calculation using the integer evaluates true. Additional query words: kbVFp500bug kbVFp500abug kbVFp600bug kbXBase ====================================================================== Keywords : Technology : kbVFPsearch kbAudDeveloper kbVFP500 kbVFP600 kbVFP500a Version : WINDOWS:5.0,5.0a,6.0 Issue type : kbbug Solution Type : kbnofix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1999.