|
Hi, i wonder if there is a function to round a number to a given number of decimals in javascript. For example, to round 2.543686 to 2.54. The (10.8).toFixed(2); doesn't work in unity, and .ToString(F2); is converting a number to a string. Thanks.
(comments are locked)
|
|
To be completely honest I don't know for sure. Maybe something like this: This will round 'randomNumber' to two decimals. If you want three decimals you can divide by 1000.0. If you want four decimals you can divide by 10000.0. And so on. Thanx! Haven't thought of that.
Dec 20 '11 at 03:18 PM
uberwleiss
(comments are locked)
|
