Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why use a 'currency' type field?
Message
De
12/05/1999 13:31:22
 
 
À
12/05/1999 13:25:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00217569
Message ID:
00217931
Vues:
17
>>>>>Dear VFP Mavens -
>>>>>
>>>>>I'm trying to understand why one would use a currency type field instead of a numeric. We have a situation which might require 5 decimal places and currency only goes to 4. I know there has to be an upside to currency vs. numeric ... could someone explain it to me?
>>>>
>>>>
>>>>I'm intrigued by why you would want to store dollars to five decimal points. That's 1/1000th of a cent, right? Perhaps it not dollars but some other currency. In that case I would lean toward a currency type flag and a table of multipliers so that a stored value of 1234.5678 Doubloons would have a multiplier of .1 (actual value 123.45678 Doubloons) while 1234.5678 Rubels might have a multiplier of 10 (actual value 12345.678 Rubels).
>>>>
>>>>I like currency fields because I can allocate 8 bytes now and be very confident that I will never have to change the size of the field in the future.
>>>>
>>>>Peter Robinson
>>>
>>>Calculate the cost for 10000 shares of Dell stock 42 13/64 per share. That's a pretty compelling reason to store a dollar amount to five or more places.
>>
>>Why? Using 10000 * (42+(13/64)) I get the same answer no mater what my decimal places are set to (422031.25)
>
>My point is, if you store 42 13/64 as a number in a table to only 2 decimal places, you get 42.20. Add more precision, and you are storing 42.203125
>
>Now the difference is
>
>422031.25 vs. 422000.00

OK, I see that point. I guess my problem is having an individual unit price in some fractional unit of the smallest denomination. (Like gas, $1.29 9/10) I do see where that does has it's place, it's just a personal pet peave of mine.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform