我知道了,原来要加上一个参数radix, 否则它会将它认为是八进制的数了,谢谢大家帮助,散分 function parseInt(numString : String [, radix : Number]) : Number Arguments: numString Required. A string to convert into a number. radix : Optional. A value between 2 and 36 indicating the base of the number contained in numString. If not supplied, strings with a prefix of '0x' are considered hexadecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal.
但是parseInt("08",10) = 8
使用parseFloat返回正常只要是第一位为0的使用parseInt就返回0
使用parseFloat返回正常只要是第一位为0的使用parseInt就返回0
function parseInt(numString : String [, radix : Number]) : Number
Arguments:
numString
Required. A string to convert into a number.
radix :
Optional. A value between 2 and 36 indicating the base of the number contained in numString. If not supplied, strings with a prefix of '0x' are considered hexadecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal.
parseInt 方法的语法有如下部分: 部分 描述
numstring 必选项。要转换为数字的字符串。
radix 可选项。在 2 和 36 之间的表示 numstring 所保存数字的进制的值。如果没有提供,则前缀为 '0x' 的字符串被当作十六进制,前缀为 '0' 的字符串被当作八进制。所有其它字符串都被当作是十进制的。
parseInt(number),如果number为01到07 函数将number视为8进制数;