General information
Category:
Coding, syntax & commands
>>>>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only