Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mathematical rounding
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00982326
Message ID:
00983081
Vues:
21
>Rounding 12.345 to one decimal...
>
>I had to do something similar many years ago in clipper. In that case it had to do with rounding cents (12.345 to 12.35).
>
>The formula I used at that time was the following:
>
>RoundedPrice = int( UnroundedPrice * 100 + .5) / 100
>
>In your case, I would do:
>
>RoundedPrice = int( UnroundedPrice * 10 + .5) / 10
>
>And the result of that would be 12.3.
>
>My opinion is that if you have doubts on which of the 47 rounding methods we have offered, you run this question by the USERS of the system. If the rounding is important and it's done in a way that doesn't match the results THEY expect, you'll end up with some code to rewrite, and this one YOU CAN call statistical rounding: you used the algorithm dictated by the majority of your users.
>
>Have fun!

<vbg>

However, 'they' told me to use mathematical rounding. It appeared 'they' didn't understand what that definition implies. (IMO, there's really only ONE correct rounding method that can be called 'mathematical rounding'.) Now I have been able to convince them: Either don't write 'mathematical rounding' in the functional design, or change the app (SAP/HR) on the receiving end. They decided to do the latter. :)
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform