From 8ecdb75d74c393895c68be7a311db959b1f373e9 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 26 Aug 2023 15:55:02 +0800 Subject: Explicitly ignore NaN values in BarMeterMode_draw() Do not throw FP exceptions if any value in a Meter object is a NaN. Signed-off-by: Kang-Che Sung --- Meter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Meter.c') diff --git a/Meter.c b/Meter.c index 27e4cd0c..5991a9c9 100644 --- a/Meter.c +++ b/Meter.c @@ -225,8 +225,9 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { int offset = 0; for (uint8_t i = 0; i < this->curItems; i++) { double value = this->values[i]; - value = CLAMP(value, 0.0, this->total); - if (value > 0) { + if (isPositive(value)) { + assert(this->total > 0.0); + value = MINIMUM(value, this->total); blockSizes[i] = ceil((value / this->total) * w); } else { blockSizes[i] = 0; -- cgit v1.2.3