Skip to content

Commit

Permalink
Explicitly ignore NaN values in BarMeterMode_draw()
Browse files Browse the repository at this point in the history
Do not throw FP exceptions if any value in a Meter object is a NaN.

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Aug 26, 2023
1 parent 076b913 commit 348cc26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 348cc26

Please sign in to comment.