Check out example codes for "string to decimal swift". It will help you in understanding the concepts better.

Code Example 1

let decimal: Decimal = 51000000000
let str = String(describing: decimal)

let savedValues = UserDefaults.standard

savedValues.set(str, forKey:"jitterClickCost")
savedValues.synchronize()

let value = savedValues.string(forKey: "jitterClickCost") ?? "0"

let result = Decimal(string: value)

Learn ReactJs, React Native from akashmittal.com