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
Here's one way to do it. You could easily do this for Float, or probably make it generic so it's for any of those.
Float
public extension CGFloat { func roundToDecimals(decimals: Int = 2) -> CGFloat { let multiplier = CGFloat(10^decimals) return round(multiplier * self) / multiplier } }