```
// 取消科学计数
classfunccancleScientific(num:String) ->String{
letformatter =NumberFormatter()
formatter.locale=Locale.current
formatter.numberStyle= .decimal
letnumber = formatter.number(from: num)
ifletn = number{
returnString(format:"%.8f", n.doubleValue)
}else{
return"0"
}
}
// 去除无效0
classfuncdeleteInvalidNum(num:String) ->String{
varoutNumber = num
vari =1
ifnum.contains("."){
whilei < num.count{
ifoutNumber.hasSuffix("0"){
outNumber.remove(at: outNumber.index(before: outNumber.endIndex))
i = i +1
}else{
break
}
}
ifoutNumber.hasSuffix("."){
outNumber.remove(at: outNumber.index(before: outNumber.endIndex))
}
returnoutNumber
}
else{
returnnum
}
}
```
网友评论