Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Currency x numeric
Message
De
28/04/2007 07:28:14
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01220406
Message ID:
01220766
Vues:
18
>Hi Terry
>
>>But that's goverend by SET DECI anyway, isn't it? So a numeric field can also have 4 decimals.
>
>Probably yes, but the field in the table will always have 4 decimals. I have never tried it this route but my fear is as follows:
>
>For eg. the calculated currency values generated and stored without rounding.
>
>123.4321
>234.5432
>--------
>357.9753 rounded 357.98
>
>123.43
>234.54
>------
>357.97

Indeed, you get different answers if you round each intermediate result, compared to rounding the final result.

Something similar happens without explicitly rounding, just by using currency values. Usually, if a calculation involves currency values, all intermediate results are converted to currency. That means, they are rounded to 4 decimals.

For example:
? a / (b * c)
where "c" happens to be of type currency, my understanding of the calculations are as follows:

For the multiplication, b must first be converted to currency. Here you may already get unexpected results, due to the rounding.

Next, the multiplication is done, rounded to 4 decimals. Finally, I suppose "a" will also be converted to currency, before doing the division.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform