Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round a number
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00174482
Message ID:
00175292
Views:
28
>>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform