PRB: Incorrect Evaluation of Equation with Variables

Last reviewed: February 28, 1997
Article ID: Q164359
5.00 5.00a WINDOWS kbprg kbprb

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 5.0

SYMPTOMS

In Visual FoxPro 5.0, an equation that contains variables may not be evaluated correctly.

STATUS

Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

In the Command window, issue the following commands:

   SET DECIMALS TO 5
   mVar = 1
   ? mVar + (1048575+(mVar/1000)) = 1048576.001

The value .T. (True) should be echoed to the screen but .F. is returned instead.

The following recommendations may be used as alternative solutions to this problem:

  • Replacing mVar (inside the parentheses) with 1 exhibits the correct behavior, as does removing the outside parentheses.
  • Using the ROUND() function may also solve this problem:

          ? ROUND(mVar+(1048575+(mVar/1000)), 5) = 1048576.001
    

This behavior does not occur in Visual FoxPro 3.0.


KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral
Additional reference words: 5.00 5.00a vfoxwin
Keywords : FxprgGeneral kbprb kbprg
Version : 5.00 5.00a
Platform : WINDOWS


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.

Last reviewed: February 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.