Stats: inRange percentage to always get a sum equal to 100%

This commit is contained in:
Philoul 2021-03-14 17:37:58 +01:00
parent 9790f1d558
commit fc78e5c0b7

View file

@ -18,7 +18,7 @@ class TIR(val date: Long, val lowThreshold: Double, val highThreshold: Double) {
fun above() = run { above++; count++ }
fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0
fun inRangePct() = if (count > 0) (inRange.toDouble() / count * 100.0).roundToInt() else 0
fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0
fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0
fun toText(resourceHelper: ResourceHelper, dateUtil: DateUtil): String = resourceHelper.gs(R.string.tirformat, dateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct())