I have this function:
extension Float {
func shortenDecimals() -> Float {
println(self)
let a = self * 10.0
println(a)
let b = round(a)
println(b)
println(b/10.0)
return b / 10.0
}
}
What this function should do is return a float with 1 decimal
This is what it prints out :
self : 0.0833333358168602
self * 10 : 0.833333373069763
round(a) : 1.0
b/10 : 0.100000001490116
I find this very frustrating, why does it not return 0.1?