📜  xcode 截断双精度的小数位数 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:00.991000             🧑  作者: Mango

代码示例1
//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