Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rounding algorithm?
Message
De
05/01/2000 10:34:33
 
 
À
05/01/2000 10:10:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00313184
Message ID:
00313202
Vues:
42
>Hi,
>
>Does anyone have a good algorithm for rounding a number (money) to the nearest 50 cents, 75 cents, etc? I'm trying to avoid breaking it down into integer and decimal components and running through a case statement. I'm hoping for some slick one or two line UDF.
>

Easiest would be to find the unit of currency divisor needed, multiply the money amount by the divisor, rounding to the nearest integer, and then dividing the result by the divisor again; eg to get to the nearest quarter:

.25 = 1/4; the divisor is 4

? ROUND(yDollarAmount * 4,0)/4
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform