(转载)Flash Number 数据类型

(转载)http://www.g168.net/txt/flash/learningactionscript/00001183.html

Number 数据类型

Number 数据类型是双精度浮点数。数字对象的最小值大约为 5e-324,最大值大约为 1.79E+308。

您可以使用加 (+)、减 (-)、乘 (*)、除 (/)、求模 (%)、递增 (++) 和递减 (--) 等算术运算符来操作数字。有关更多信息,请参见使用数值运算符

您也可使用内置的 Math 和 Number 类的方法来操作数字。有关这些类的方法和属性的更多信息,请参见"ActionScript 2.0 语言参考"中的 Math 和 Number 条目。

下面的示例使用 Math 类的 sqrt()(平方根)方法返回数字 100 的平方根:

Math.sqrt(100);

下面的示例输出一个 10 到 17(含 10 和 17)之间的随机整数:

var bottles:Number = 0;
bottles = 10 + Math.floor(Math.random() * 7);
trace("There are " + bottles + " bottles");

下面的示例查找加载的 intro_mc 影片剪辑的百分比,并将百分比表示为整数:

var percentLoaded:Number = Math.round((intro_mc.getBytesLoaded() / intro_mc.getBytesTotal()) * 100);
原文地址:https://www.cnblogs.com/Robotke1/p/3306911.html