Use rounding to prevent incorrect backlight percentage calculation (#236)

This commit is contained in:
Mirei124
2023-03-31 00:45:44 +08:00
committed by GitHub
parent 81bf4bdb39
commit a2397da06a

View File

@@ -116,11 +116,11 @@ namespace SwayNotificationCenter.Widgets {
} }
private int calc_percent (int val) { private int calc_percent (int val) {
return val * 100 / max; return (int) Math.round (val * 100.0 / max);
} }
private int calc_actual (float val) { private int calc_actual (float val) {
return (int) val * max / 100; return (int) Math.round (val * max / 100);
} }
public int get_max_value () { public int get_max_value () {