Search code examples
visual-foxprofoxpro

foxpro double data type precision


I have a table that has numeric columns that are double data type with 2 decimals. We are migrating the data to a new system and noticed that the totals after migration didn't match. It seems that data is being stored beyond the hundredths place. How is that possible with double(2)?

Shouldn't something like this return 0.00?

CREATE CURSOR temp ( fld_dbl2 b(2))
FOR n=1 TO 1000
    APPEND BLANK
    replace fld_dbl2 WITH RAND()/1000
ENDFOR

SELECT SUM(fld_dbl2) FROM temp
into cursor _csrTemp

Solution

  • From the VFP 9 help file:

    When the Double data type is used in a table, the number of decimals specified when the field is created is for display purposes only. Visual FoxPro stores the actual value in the field.