How to convert Decimal
to String
in swift?
For example
let de = Decimal(string: "123")
then how to convert de
to String.
Leveraging the fact that Decimal conforms to protocol CustomStringConvertible
I would simply do:
let decimalString = "\(de)"
Convert to NSDecimalNumber and use the stringValue.
NSDecimalNumber(decimal: de).stringValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With