In actionscript 3, I have a user enter a number into a field and this field is supposed to be for a cash value. How do I make it so that if for some reason they put say 20.956, it would round up to 20.96?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
toFixed(). Something like:It’s not mentioned in the documetnation, but i’m fairly sure it rounds rather than floors.
Notice that
.toFixed()returns a string, if you want a more comprehensive helper then you could use something like the following.and invoke it using:
And actually you can use negative numbers for the decimalPlaces as well