Microsoft KB Archive/88238

{| = PRB: AVERAGE Command Ignores SET DECIMALS =
 * width="100%"|

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
 * }