Check out example codes for "swift truncate a float". It will help you in understanding the concepts better.

Code Example 1

let formatted = String(format: "Angle: %.2f", angle)

Learn ReactJs, React Native from akashmittal.com