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

Code Example 1

let tip: Double = 15.2847320
let tipText: String = String(format: "%.2f", tip)
// %.2f for two decimal places

Learn ReactJs, React Native from akashmittal.com