Below is how I would have previously truncated a float to two decimal places
NSLog(@\" %.02f %.02f %.02f\", r, g, b);
I checked the docs an
extension Double { func formatWithDecimalPlaces(decimalPlaces: Int) -> Double { let formattedString = NSString(format: "%.\(decimalPlaces)f", self) as String return Double(formattedString)! } } 1.3333.formatWithDecimalPlaces(2)