This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Double { | |
// Given a value to round and a factor to round to, | |
// round the value to the nearest multiple of that factor. | |
mutating func round(toNearest: Double) { | |
self = (self / toNearest).rounded() * toNearest | |
} | |
// Given a value to round and a factor to round to, | |
// round the value DOWN to the largest previous multiple | |
// of that factor. |