import Foundation

extension Double {

    func rounded(to interval: Double) -> Double {
        (self / interval).rounded() * interval
    }

    func rounded(decimals: Int) -> Double {
        let factor = Double.pow(10.0, Double(decimals))
        return (self * factor).rounded() / factor
    }
}
