您的位置:首页 > 其它

内部类型转换方法-ToInt32

2013-08-18 20:43 183 查看

ToInt32: (Signed 32 Bit Integer)

The abstract operation ToInt32 converts its argument to one of 232 integer values in the range −231 through231−1, inclusive. This abstract operation functions as follows:Let number be the result of calling ToNumber on the input argument.

If number is NaN, +0, −0, +∞, or −∞, return +0.

Let posInt be sign(number) * floor(abs(number)).

Let int32bit be posInt modulo 232;
that is, a finite integer value k of Number type with positive sign and less than 232 in magnitude such that the mathematical difference of posInt and k is mathematically an integer multiple of 232.

If int32bit is greater than or equal to 231, return int32bit − 232, otherwise return int32bit.

sign , floor , abs , modulo 用法参见-> 这里

翻译成中文 !!!

抽象方法ToInt32将传入的参数转换成(-2^31,2^31-1]中的一个值。这个抽象方法的执行过程如下:1.将传入参数进行ToNumber转换,设结果为number2.如果number是NaN, +0, −0, +∞, or −∞ 直接返回03.设posInt 为sign(number) *floor(abs(number)) 4.设int32bit为posIntmodulo 2^32的值5.如果int32bit大于等于2^31,返回int32bit − 2^32, 否则返回 int32bit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息