# PRB： 計算標準--標準差--提供數值溢位

##### 解決方案

``   * Call this program by ?std("TableName","FieldName") or   * by assigning the result to a variable, y= std("TableName","FieldName")   *      PARAMETER mtable mfield      SELECT SUM(&mfield^2) FROM (mtable) INTO ARRAY yy      SELECT SUM(&mfield)^2 FROM (mtable) INTO ARRAY zz      SELECT COUNT(&mfield) FROM (mtable) INTO ARRAY xx      stdev=((xx*yy-zz)/xx^2)^.5      RETURN ROUND(stdev,12)				``

``   ?std("values","num")				``
##### 狀況說明
Microsoft 研究這個問題，並且將張貼新資訊 「 Microsoft 知識庫 」 中可用時。

### 重製行為的步驟

``   CLEAR   SET SAFETY OFF   SET DECIMALS TO 12   CREATE TABLE stdresult (num N(15,8)) &&Table for result of calculation   APPEND BLANK   CREATE TABLE stdtest (num N(15,8))   &&Table of values for calculation   FOR i = 1 TO 10      INSERT INTO stdtest(num) VALUES (0.031)   ENDFOR   FOR i = 1 TO RECCOUNT()      ?ALLTRIM(STR(i))+" "      SET TALK OFF      CALCULATE STD(num) FOR RECNO()<i TO nresult && Comment this line &                                                  && the next line once                                                  && you uncomment the                                                  && commented lines below.      ??nresult      *nresult=custstd('stdresult','num') && Uncomment this line & the next                                          && line to compute & display the                                          && standard deviation with a                                          && user-defined function.      *?nresult      SELECT stdresult      REPLACE num WITH nresult   &&Overflow error on 10th iteration      SELECT stdtest   ENDFOR   SET SAFETY ON   SET TALK ON   SET DECIMALS TO 2   PROCEDURE custstd   PARAMETER mtable mfield   SELECT SUM(&mfield^2) FROM (mtable) INTO ARRAY yy   SELECT SUM(&mfield)^2 FROM (mtable) INTO ARRAY zz   SELECT COUNT(&mfield) FROM (mtable) INTO ARRAY xx   stdev=((xx*yy-zz)/xx^2)^.5   RETURN ROUND(stdev,12)				``

#### 警告：本文為自動翻譯

Microsoft Visual FoxPro 3.0 Standard Edition, Microsoft Visual FoxPro 3.0b Standard Edition, Microsoft Visual FoxPro 5.0 Standard Edition, Microsoft Visual FoxPro 5.0a, Microsoft Visual FoxPro 3.0 for Macintosh

• kbnosurvey kbarchive kbmt kbcode kbprb KB172084 KbMtzh