ParseInt
发布时间:2020-12-14 06:38:03 所属栏目:Java 来源:网络整理
导读:转自: p align="left" style="color:rgb(51,51,51);font-family:Arial;font-size:14px;"span style="font-family:'Courier New';font-size:16px;"span style="line-height:20px;font-size:13px;"ParseInt(span style="line-height:22px;font-size:14px;"str
转自: <p align="left" style="color:rgb(51,51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;">ParseInt(<span style="line-height:22px;font-size:14px;">str:String,radix:uint <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">参数: <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">str:String 要转换为整数的字符串 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">radix:uint?(default =?0)?— 表示要分析的数字的基数(基)的整数。合法值为 2 到 36。 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="color:rgb(51,102,255);">即被解析的字符串本身属于哪种类型的数据,二进制,八进制.... <p align="left" style="color:rgb(51,255);">例如要将二进制数100101110转换为整数,就要这样写<span style="color:rgb(51,153,102);">parseInt("<span style="color:rgb(255,0);">100101110",<span style="color:rgb(255,0);">2) <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;"> <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;">输出: <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"> <span style="color:rgb(51,51);font-family:'Courier New';font-size:16px;"><span style="color:rgb(51,51);font-family:Arial;font-size:14px;"> <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("ABC")=NaN <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123.0123")=123 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="color:rgb(255,0);">parseInt(" a456")=NaN <p align="left" style="color:rgb(51,0);">parseInt("456b123")=456 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt(" 789 ")=789 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"> <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int("ABC")=0 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int("123.0123")=123 <p align="left" style="color:rgb(51,0);">int(" a456")=0?<span style="color:rgb(51,102);">如果要转换的是非有效字符串,则返回0 <p align="left" style="color:rgb(51,0);">int("456b123")=0 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int(" 789 ")=789 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123")=123 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("0123")=123 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("0x123")=291?<span style="color:rgb(51,102);">将十六进制数0x123转换为整数就是29<span style="color:rgb(51,102);">1 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("100101110",2)=302?<span style="color:rgb(51,102);">将二进制数“100101110”转换为整数就是302 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("100",8)=64 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123",10)=123 <p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("263a",16)=9786 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |