BUG: CALCULATE SUM() Results Differ Based on SET DECIMAL

Last reviewed: June 27, 1995
Article ID: Q113209
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, version 2.5b

SYMPTOMS

Issuing the CALCULATE SUM() command with a field as the argument to SUM() will return values other than 0 (zero) past the second decimal place if SET DECIMALS TO is set to greater than 2. However, this behavior should never occur if the field is defined as having only two decimals.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

Run the following code from a program:

   SET SAFETY OFF
   SET TALK OFF
   =RAND(-1)
   CREATE TABLE test (VALUE N(10,2))
   FOR i = 1 TO 2000
        INSERT INTO test (VALUE) VALUES (RAND()*100)
   NEXT i
   SET DECIMAL TO 2
   CALCULATE SUM(VALUE) TO val1
   SET DECIMAL TO 14
   CALCULATE SUM(VALUE) TO val2
   ?"VAL1 ="
   ??val1
   ?"VAL2 ="
   ??val2
   SET TALK ON
   SET SAFETY ON

The output that this program produces will look something like the following, although the values will be different:

   VAL1 =        7483984.34
   VAL2 =        7483984.33999998000000

   -or-

   VAL1 =        7483984.34
   VAL2 =        7483984.34000000001000

NOTE: You may have to run the program several times before you will see this behavior.

However, the output should look like the following:

   VAL1 =        7483984.34
   VAL2 =        7483984.34000000000000

VAL2 should have zeros only from the third decimal place on because TEST.VALUE is defined in the table as being only two decimal places wide.


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
buglist2.00
buglist2.50
buglist2.50a buglist2.50b round conversion 2.60 buglist2.60
KBCategory: kbprg kbbuglist
KBSubcategory: FxprgGeneral


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.