function htoi(hex){
if(hex.length != 2){
alert("参数不正常:"+hex);
}
else{
var a = hex.toLowerCase().charCodeAt(0);
var b = hex.toLowerCase().charCodeAt(1);
if(a>47 && a<58){
a = (a-48)*16;
}
else if(a>96 && a<103){
a = (a-87)*16;
}
else{
alert("参数错误");
return 0;
}
if(b>47 && b<58){
a = a+b-48;
}
else if(b>96 && b<103){
a = a+b-87;
}
else{
alert("参数错误");
return 0;
}
return a;
}
}
js 16进制转10进制
最新推荐文章于 2022-12-01 10:45:54 发布