diff --git a/brightnessctl.c b/brightnessctl.c index 7b88a53..cc2b2d7 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -370,7 +370,7 @@ float val_to_percent(float val, struct device *d, bool rnd) { } unsigned long percent_to_val(float percent, struct device *d) { - return roundf(powf(percent / 100, p.exponent) * d->max_brightness); + return roundf(powf(fmaxf(percent, 0) / 100, p.exponent) * d->max_brightness); } void print_device(struct device *dev) {