I am receiving two kid of Doubles from JSON:
1.12
and 0.00007067999999
The second number switches automatically to scientific notation(
7.067e-05), so I'm using the function String(format:"%.8f", NUMBER)
to make it 0.00007067
, yes it works, but now my first number becomes 1.12000000
.
How to clean trailing numbers?
I've tried with Swift - Remove Trailing Zeros From Double , but the %g
format changes second number to scientific notation again, so %g
is not an option. Any suggestions?