Decimal point in calculations as . or ,

前端 未结 4 974
余生分开走
余生分开走 2021-01-23 01:48

If I use decimal pad for input of numbers the decimal changes depending of country and region format.
May be as a point \".\" or as a comma \",\"
And I do not have contr

4条回答
  •  我在风中等你
    2021-01-23 02:19

    Identify is local country uses comma for decimal point

    var isUsesCommaForDecimal : Bool {
        let nf = NumberFormatter()
        nf.locale = Locale.current
        let numberLocalized = nf.number(from: "23,34")
        if numberLocalized != nil {
            return true
        } else {
            return false
        }
    }
    

提交回复
热议问题