user1825271
user1825271

Reputation: 77

Large numbers rounding AS3

I've a huge numbers, for example 1.98726575488820e+30, and i want to rounding it to this form: floor + "." (without quoting) + five-digit mantissa + "e+..." (if there is e) but I don't know how can I do it. In this case: 1.98727e+30.

Please so much for help.

Upvotes: 2

Views: 189

Answers (1)

David Mear
David Mear

Reputation: 2254

Number.toPrecision will give you a String like this:

var hugeNumber:Number = Number("1.98726575488820e+30");
var rounded:String = hugeNumber.toPrecision(6);
trace(rounded); // "1.98727e+30"

Upvotes: 3

Related Questions