While playing around, I found the round() function in swift. It can be used as below:
round(0.8)
Which will return 1, as expected. Here\'s
The round(someDecimal) is the old C style. As of Swift 3, doubles and floats have a built in Swift function.
var x = 0.8
x.round() // x is 1.0 (rounds x in place)
or
var x = 0.8
var y = x.rounded() // y is 1.0, x is 0.8
See my answer fuller answer here (or here) for more details about how different rounding rules can be used.
As other answers have noted, if you want to round to the thousandth, then multiply temporarily by 1000 before you round.