-1

How do I convert a string to double or float without losing precision

ex.

let stringNumber = "12.00"

1 Answers1

1

What you want to use is NSString(format:) for the visual format of your value.

Swiftstub sample

To always show 2 digits visually use this:

NSString(format: "%.2f", value)
Arbitur
  • 38,684
  • 22
  • 91
  • 128