Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round a number
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00174482
Message ID:
00175292
Vues:
29
>>>>How can I take a number like 1.345 and round it to a specific precision like .2?
>>>>
>>>>1.3456 precision .2 = 1.4
>>>>1.6345 precision .5 = 1.5
>>>>1.3456 precision .005 = 1.345

>
>I don't think that was what he was looking for... He needed it to be more generic to accommodate multiple decimal precision and what if the precision factor was .725??? How would your solution accommodate this... For each decimal level out, you would also have to change the int( x*100)/100.

Don, you are correct I need to round to a specific precision as stated above.

I came up with the following line that seemed to work ok. If you can suggest something better I am all ears...

#DEFINE STEPDIST .1
#DEFINE PRECISION .005
#DEFINE STEPANGLE 45

lnXOrigin = (ROUND(ROUND(XOrigin, PRECISION) / STEPDIST,0)) * STEPDIST

Thanks
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform