format decimal place swift
let tip: Double = 15.2847320
let tipText: String = String(format: "%.2f", tip)
// %.2f for two decimal places
format decimal place swift
let tip: Double = 15.2847320
let tipText: String = String(format: "%.2f", tip)
// %.2f for two decimal places
xcode truncate number of decimal places of double
//Multiply the double you want to round by 10^(the number of decimal place precision you want), use the "round()" function, then divide by that number again
let x = 1.23556789
let y = Double(round(1000*x)/1000)
print(y) // 1.236
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us