Commit: f7dc79f0d995d0652b4e5d512d98b30d2cb64e7f
Parent: 038e054e0702867274e9b2f54670044bc0707dbf
Author: Randy Palamar
Date: Sun, 29 Dec 2024 09:31:42 -0700
linux/battery_info.c: avoid big float jank
my laptop was showing 101% at full charge. we need to perform the
division before scaling up 100x unless we want to get owned by
float precision issues
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blocks/linux/battery_info.c b/blocks/linux/battery_info.c
@@ -26,7 +26,7 @@ static BLOCK_UPDATE_FN(battery_info_update)
energy_now = read_i64(stream_ensure_c_str(&lbd->path_base));
lbd->path_base.write_index = sidx;
- f32 percent = (100 * energy_now / (f64)lbd->energy_full) + 0.5;
+ f32 percent = 100 * (energy_now / (f64)lbd->energy_full) + 0.5;
b32 warn = percent < ba->thres;
char state_buffer[16] = {0};