Round down in perf stats

pull/9635/head
Philipp Leclercq 2021-08-22 20:31:36 +02:00
parent a494701fed
commit f0ddc0e5c2
2 changed files with 5 additions and 1 deletions

View File

@ -71,7 +71,7 @@ object perfStat {
}
}
private def decimal(v: Double) = lila.common.Maths.roundAt(v, 2)
private def decimal(v: Double) = lila.common.Maths.roundDownAt(v, 2)
private def glicko(u: User, perfType: PerfType, perf: Perf, percentile: Option[Double])(implicit
ctx: Context

View File

@ -23,6 +23,10 @@ object Maths {
BigDecimal(n).setScale(p, BigDecimal.RoundingMode.HALF_UP)
}
def roundDownAt(n: Double, p: Int): BigDecimal = {
BigDecimal(n).setScale(p, BigDecimal.RoundingMode.DOWN)
}
def closestMultipleOf(mult: Int, v: Int): Int =
((2 * v + mult) / (2 * mult)) * mult