///字符串转双精度后去除小数点00
    static func convertStringToString(_ str: String) -> String? {
        if let doubleValue = Double(str) {
            let numberFormatter = NumberFormatter()
            numberFormatter.minimumFractionDigits = 0
            numberFormatter.maximumFractionDigits = doubleValue.truncatingRemainder(dividingBy: 1) == 0 ? 0 : 2
            return numberFormatter.string(from: NSNumber(value: doubleValue))
        }
        return nil
    }

 

posted on 2024-04-12 11:56  懂事长qingzZ  阅读(74)  评论(0编辑  收藏  举报