How do I round so that 4.6000 will turn into 5? Or anything before 4.5000 turn into the next number. Like 1.5000 will be 2.0000. Thank you for your help.
will return:
4.0 if value was 4.4
4.5 if value was 4.5
5.0 if value was 4.6 -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
MikeLacey: sorry mike, you are just cutting decimals
this is not really rounding... -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
OpenWater has it right, the absolute fastest way to round is to add 0.5 and truncate. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
Out of curiosity, I performed a crude test to see the difference in speed by rounding the same number 10 million times...
OpenWater's method was indeed the fastest at a blistering 16 seconds.
it seems my silly clusterf**k of a program wasn't as slow as I thought it would be - it was tied with MikeLacey's method at about 46 seconds.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.