Numeric Overflow (data was lost) ERROR 39

 

Basically this error says, the resulting number is too large.

- dBASE IV has a numeric accuracy of, TYPE F - 15.9 digits, TYPE N, 10 to 20 digits based on the settings of SET PRECISION TO <expN>. Operations that exceed this accuracy may produce the error message "Numeric overflow (data was lost)." [39].

If a resulting number is greater than dBASE numeric accuracy, you might consider storing your data in 2 fields one for the number without the e (the integer portion) and a second field for the e (multiplier).

  • You can get this error if your resulting number can not fit into the destination. For example, a file contains the following field:

    Field Field name Type Width Dec
    1 Num_fld Numeric 6 2

The REPLACE command can input integers up to six digits without numeric overflow. REPLACEing Num_fld with a seventh digit integer (including the decimal) displays the error message "Numeric overflow (data was lost)." [39].

Trapping, Numeric Overflow Error (data may have been lost) [39]

In theory you should be able to trap this with an ON ERROR routine because if we look in the back of the Lang. Ref. dBASE ERROR MESSAGES this error has a number [39]. However this is NOT a trapable error.

Approaches to Trapping this error:

- Check the number BEFORE attempting to REPLACE a field.

IF mvar <= 999.99 .AND. mvar => -999.99 
   * Where 999.99 is the largest number that 
   * will fit in num_fld 6,2 
   REPLACE num_fld WITH mvar 
ELSE 
   ?"Number to big" 
ENDIF 

- Be aware that an illegal math operation such as dividing by 0 will also cause this error.

x = 1 
y = 0 
REPLACE num_fld WITH x/y 

In this case you want to check to make sure the dominator is not zero.

mvar = IIF(y<>0, x/y, 0) 
* IF x not equal to 0, return x/y ELSE return 0. 
REPLACE num_fld WITH mvar 

- You can test whether a numeric overflow occurred after the REPLACE with

IF "*"$STR(num_fld) 
* Or clean it up after the fact. 
REPLACE ALL num_fld WITH 0 FOR "*"$STR(num_fld) 

- To avoid SEEING the error message you can

SET CONSOLE OFF 
REPLACE num_fld WITH too_big_num 
SET CONSOLE ON 

- Small decimal numbers displayed using a PICTURE clause are handled differently by dBASE III PLUS and dBASE IV. Numbers that are too small to display with a given PICTURE clause were displayed as zero in dBASE III PLUS, whereas in dBASE IV these values are displayed as asterisks ("numeric overflow"). Although this is incompatible with dBASE III PLUS, dBASE IV is more consistent in the way it handles numbers that do not fit the specified PICTURE clause (e.g. both products display numbers that are too large for a template as asterisks, or overflow).

Since SET FIXED is disabled in dBASE IV, the number of decimals displayed is determined only by the PICTURE clause. Also, the number of decimals set by SET DECIMAL TO has a stronger effect on the rounding of numbers in dBASE III PLUS than in dBASE IV. That is, dBASE IV automatically rounds numbers regardless of the value of SET DECIMAL, whereas dBASE III PLUS rounds numbers only according to the DECIMAL setting (see examples below).

EXAMPLE:

In dBASE III PLUS: In dBASE IV:
? TRANSFORM(1234,"99")
  **
  x = .001 
? TRANSFORM(x,"99")
  0
? TRANSFORM(x,"9.99")
  0.00
? TRANSFORM(x,"9.999")
  0.000
SET DECIMAL TO 3
? TRANSFORM(x,"9.999")
  0.001
? TRANSFORM(1234,"99")
  **
  x = .001
? TRANSFORM(x,"99")
  0
? TRANSFORM(x,"9.99")
  *.**
? TRANSFORM(x,"9.999")
  0.001
SET DECIMAL TO 3
? TRANSFORM(x,"9.999")
  0.001
* -- Change the value of x to show rounding
x = .009
? TRANSFORM(x,"9.99")
  0.01
? TRANSFORM(x,"9.999")
  0.010
SET DECIMAL TO 3
? TRANSFORM(x,"9.999")
  0.009
x = .009
? TRANSFORM(x,"9.99")
  0.01
? TRANSFORM(x,"9.999")
  0.009

* No difference in dBASE IV.

dBASE IV is actually handling the PICTURE clause more consistently and accurately than dBASE III PLUS did.

[Home] [FAQ Index]