Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Serious Error with Currency Data Type
Message
 
 
To
18/01/1999 19:37:16
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00177250
Message ID:
00177458
Views:
48
Calvin,

You have a 3rd normal form relational database with 1000 columns of currency data in the tables? That in itself is pretty staggering.

How many places does the multiply operation occur? A simple change of your posted code from:

? $1050.45 * .41116

to

? ntom( mton( $1050.45 ) * .41116 )

does yield the precision you want. The Currency datatype is designed to hold large values, lots of digits to the left of the decimal point. The 4th decimal place is very insignificant when you consider the total range of values that can be stored in that data type. The example you post makes the difference seem more significant than the 0.009729% roundoff error. Numeric precision is always governed by the operand with the smallest precision, in this case the currency value.

In what context do you want to GOMONTH() on a currency data type?

If all these fields are involved in multiplies that need more than 4 decimal digits of precision and you need to change them to numeric you could write a PRG that would automate the ALTER TABLE process.

>The manual does say 'Use the Currency data type instead of Numeric for monetary values. If you specify more than four decimal places in a currency expression, Visual FoxPro rounds to four places before evaluating the expression...'. However, this is a serious thing and I for one do not believe that this explanation is in any way sufficient to explain the effect of following the [very clear] recommendation to use currency rather than numeric values at the beginning of the above quote. I can see now that I was foolish, but that does not make me any less pi...ed off. I now have to go back and change approximately 1000 fields in my database to numeric values and who knows what trouble that is going to cause. I have discovered some other little goodies - gomonth will not accept a number that is of type currency.
>
>I have now RTFM and my question now becomes- Of what use is the currency type if you can't do any d..m thing with it.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform