Answers for "decimal rounding error in swift 5"

1

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
Posted by: Guest on August-30-2020

Code answers related to "decimal rounding error in swift 5"

Code answers related to "Swift"

Browse Popular Code Answers by Language