session-ios/SignalMessaging/Loki/CGFloat+Rounding.swift
Niels Andriesse 1338fcda21 Clean
2019-09-10 13:26:58 +10:00

9 lines
250 B
Swift

extension CGFloat {
/// Round the number to the given amount of decimal places.
func rounded(toPlaces places:Int) -> CGFloat {
let divisor = pow(10.0, CGFloat(places))
return (self * divisor).rounded() / divisor
}
}