/**
*
* @param str string字符串
* @return int整型
*/
function atoi( str ) {
// write code here
if(!str) return 0;
str = str.trim()
if(str.length){
var res = parseInt(str)
const min = Math.pow(-2,31)
const max = Math.pow(2,31)-1
if(res<min){
return min
}
if(res>max){
return max
}
}
return res
}
module.exports = {
atoi : atoi
};
字符串化为整数
猜你喜欢
转载自blog.csdn.net/weixin_45284354/article/details/113826604
今日推荐
周排行