I have a string
let str = "2.1"
I want to cast it in Double and always have 2 digits after the separator like that :
let double = 2.10
So what I do is :
let formatter = NumberFormatter()
formatter.decimalSeparator = "."
formatter.minimumFractionDigits = 2
let myDoubleValue = formatter.number(from: str)?.doubleValue
And the output is still with only 1 fraction digit : 2.1
why ?