Merge pull request #9635 from PhilLecl/issue-9605

Round down in perf stats
pull/9637/head
Thibault Duplessis 2021-08-23 11:44:59 +02:00 committed by GitHub
commit 6ef9d57384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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