PDA

View Full Version : Simple decimal question



pixel_chick
July 24th, 2008, 03:31 PM
I have an XML node that is a percentage, <Percentage>.1578578928946447322</Percentage> that needs to be displayed as 15% instead of what is shown. Can anyone tell me how to move the decimal to accomplish this? Seems like it should be pretty straight forward, but can't seem to find the answer anywhere. Thanks!

sekasi
July 24th, 2008, 03:33 PM
var val:Number = 0.157345345;
trace(Math.round(val*100));

Do Math.floor instead if you always want to round down btw..

pixel_chick
July 24th, 2008, 03:41 PM
Thank you sekasi!