问题
how can I round number to up down or to the 0.5 using action script 3.0 for example
- 4.9 will 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.
回答1:
How about
Math.round(2 * number_here) / 2
回答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;
来源:https://stackoverflow.com/questions/6889312/how-to-round-number-in-actionscript