-
StackOverflow 文档
-
ActionScript 3 教程
-
使用数值
-
显示所需精度的数字
var a:Number=0.123456789;
trace(a); // 0.123456789
trace(a.toPrecision(4)); // 0.1235
trace(a.toFixed(4)); // 0.1235
trace(a.toExponential(4)); // 1.2345e-1
trace(a.toString(16)); // 0 - works for integer part only
var b:Number=12345678.9876543; // a bigger number to display rounding
trace(b); // 12345678.9876543
trace(b.toPrecision(4)); // 1.235e+7
trace(b.toFixed(4)); // 12345678.9877
trace(b.toExponential(4)); // 1.2345e+7
trace(b.toString(16)); // bc614e
b=1.0e+16;
trace(b.toString(36)); // 2qgpckvng1s