If you need to use a rounded number in future math exercises, you can use the following function:
func floorToPlaces(value:Double, places:Int) -> Double {
let divisor = pow(10.0, Double(places))
return floor(value * divisor) / divisor
}
Then you can call it with
var value: AnyObject = dict.valueForKey("XXX")!
var rounded = floorToPlaces(value.doubleValue, 1)
var stringVal = "\(rounded)"
What this actually did was the following:
15.96 * 10.0 = 159.6
floor(159.6) = 159.0
159.0 / 10.0 = 15.9
Caution: this help will not be in situations where you use scientific accuracy, i.e.
1.49850e0 --> 1.4e0
1.39e10 --> 1.3e10
It will treat all numbers as e0