# Number Number 对象是经过封装的能让你处理数字值的对象。 ## 实例方法 ### toFixed(fractionDigits?) ```ts function financial(x: Number): String { return x.toFixed(2); } console.log(financial(123.456)); // expected output: "123.46" console.log(financial(0.004)); // expected output: "0.00" ``` ### toString() ** 已知问题:目前android 平台 Number.toString() 不支持进制参数,这个问题稍后会修复 ** ### valueOf() ### toInt() ```ts let a = 12 console.log(a.toInt()); // expected output: 12 // Int最大值2147483647,溢出了 let b = 2147483648 // expected output: -2147483648 ``` ### toFloat() ### toDouble() ### toUInt() ### toByte() ```ts let a = 12 console.log(a.toByte()); // expected output: 12 ``` ### toLong() ```ts let a = 12 console.log(a.toLong()); // expected output: 12 ``` ### toShort() ### toUShort() ### toULong() ### toInt64() ### toInt32() ### toInt16() ### toInt8() ### toUInt64() ### toUInt32() ### toUInt16() ### toUInt8() ## 静态方法 ### from() ```ts let a: Int = 12 let b = Number.from(a) console.log(b); // expected output: 12 ```