6 Replies Latest reply on Sep 21, 2007 6:40 AM by Newsgroup_User

# round input number to 2 place

I have a score of numbers that total up percent, but get like 25.22222222%. These are input numbers so don't know value until until put in.
How do I set it to only pull up 2 decimal places?

thks
• ###### 1. Re: round input number to 2 place
Hi --

The easiest way is to multiply by 100, use the Math.parseInt() function and
then divide the remaining number by 100. This would turn 25.2222222 into
2522.222222, then the parseInt function will get you 2522 and then you
divide by 100 and get 25.22.

Rich

"maureen27" <webforumsuser@macromedia.com> wrote in message
news:fcsk16\$1rg\$1@forums.macromedia.com...
>I have a score of numbers that total up percent, but get like 25.22222222%.
>These are input numbers so don't know value until until put in.
> How do I set it to only pull up 2 decimal places?
>
> thks

• ###### 2. Re: round input number to 2 place
I tried attached.

Now I don't get an answer at all.

Can you help me word it?
• ###### 4. Re: round input number to 2 place
o.O
As Rich said...
Using 33.3333333 as an example:

First you multiply by 100.
> Resulting in 3333.33333

Then you use the parseInt function to turn that number into an integer (though, it might be better to use the Math.round() method instead?):
> You end up with 3333.

Then you divide it back by 100.
> And you end up with 33.33.
• ###### 5. Re: round input number to 2 place
Sorry, but I'm trying to learn this and still not getting it. Can you write sample in code, where the number is not known until it is loaded in dynamic text box.

Thnks

• ###### 6. Re: round input number to 2 place
var x = 33.333333

x = x * 100

x = Math.parseInt(x)

x = x / 100

Now x should equal 33.33

"maureen27" <webforumsuser@macromedia.com> wrote in message
news:fcutlu\$ou9\$1@forums.macromedia.com...
> Sorry, but I'm trying to learn this and still not getting it. Can you
> write sample in code, where the number is not known until it is loaded in
> dynamic text box.
>
> Thnks
>
>
>
>