Begin statistics creation
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import Foundation
|
||||
import _math
|
||||
|
||||
extension Double {
|
||||
|
||||
func rounded(to interval: Double) -> Double {
|
||||
(self / interval).rounded() * interval
|
||||
}
|
||||
|
||||
func rounded(decimals: Int) -> Double {
|
||||
let factor = _math.pow(10.0, Double(decimals))
|
||||
return (self * factor).rounded() / factor
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user