|
From: ShaneHoffa on 30 Sep 2006 11:41 How do I round a number to a specific decimal point value in javascript? Example: a value of 1.845698. I need Director to convert it to 1.84. Thank you. Shane
From: duckets on 2 Oct 2006 05:18 Perhaps you could multiply by 100, then use parseInt(), then divide by 100? - Ben
From: Ex Malterra on 2 Oct 2006 09:44 you can use toFixed(2) to round the value to 2 decimal places. you won't get 1.84 though, you'll get 1.85 because the thirde decimal place is 5. 5 or higher gets rounded up. toFixed technically returns a string, but javascript isn't strongly typed so that's not really an issue. if you atempt an arithemetic operation on "1.85" the value is automatically type cast to a number. so 2*"1.85" will return the same as 2*1.85.
|
Pages: 1 Prev: To run an exe with lingo script Next: WMV Volume Control |