1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

fix decimal conversions

This commit is contained in:
Caio Freitas de Oliveira 2022-10-05 00:22:58 -03:00 committed by Brenden Matthews
parent 033508a93e
commit 3400324fab

View File

@ -51,18 +51,18 @@ long to_decimal_scale(long value, long max_value) {
if (value == 0) {
return 0;
} else if (value > 0) {
return (value * CONST_SCALE + max_value - 1) / max_value;
return (value * CONST_SCALE) / max_value;
}
return -((std::abs(value) * CONST_SCALE + max_value - 1) / max_value);
return -((std::abs(value) * CONST_SCALE) / max_value);
}
long from_decimal_scale(long value, long max_value) {
if (value == 0) {
return 0;
} else if (value > 0) {
return (value * max_value + CONST_SCALE_HALF) / CONST_SCALE;
return (value * max_value) / CONST_SCALE;
}
return -((std::abs(value) * max_value + CONST_SCALE_HALF) / CONST_SCALE);
return -((std::abs(value) * max_value) / CONST_SCALE);
}
long cap_scaled_color(long colour) {