how can I round number to up down or to the 0.5 using action script 3.0 for example
- 4.9 w开发者_如何转开发ill be rounded to 5
- 4.7 will be rounded to 4.5
- 2.4 will be rounded to 2.5
- 2.3 will be rounded to 2
thank you.
How about
Math.round(2 * number_here) / 2
z = Math.floor(n);
p = n-z;
if(p<0.25)
ans=z;
else if(p>0.75)
ans=z+1;
else
ans=z+0.5;
精彩评论