PRB: AVERAGE Command Ignores SET DECIMALS

Last reviewed: July 26, 1995
Article ID: Q88238
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SYMPTOMS

If the SET DECIMALS command is used to specify a certain number of decimal places for display and the AVERAGE command is then used to calculate the average value of a numeric field in a database, the average is displayed with a different number of decimal places than the specified value.

CAUSE

The result returned by the AVERAGE command contains the number of decimal places specified in the field definition of the database file structure.

RESOLUTION

To obtain an average with the number of decimal places specified in the SET DECIMALS command, use the CALCULATE AVG() command.

MORE INFORMATION

For example, consider a database that has a numeric field called SALES with two decimal places specified in the file structure. The SET DECIMALS TO 0 command specifies no decimal places in the result. Assuming that the average of the SALES column computes to 10,523.45, the AVERAGE and CALCULATE AVG() commands return different results, as follows:

   AVERAGE SALES returns 10,523.45
   CALCULATE AVG(SALES) returns 10,523

Use the command that returns the desired number of decimal places.


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbprg kbprb
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: July 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.