Skip to content

Commit

Permalink
makeDetailsMask() cast to int test
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Jan 24, 2024
1 parent f8fe41c commit 6850aa3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,16 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
assert(blanksAtTopCell < 8);
blanksAtEnd = (uint8_t)blanksAtTopCell;
roundsUpInAscii = true;
} else if (prev->nCellsPainted == 0 || prev->topPoint <= prev->nCellsPainted) {
} else if (prev->nCellsPainted == 0 || prev->topPoint <= (double)(int)prev->nCellsPainted) {
blanksAtEnd = (uint8_t)((1.0 - rem) * 8.0) % 8;
} else if (new->nCellsPainted > new->topPoint) {
assert(new->nCellsPainted - new->topPoint < 1.0);
} else if ((double)(int)new->nCellsPainted > new->topPoint) {
assert((int)new->nCellsPainted - new->topPoint < 1.0);
// Unlike other conditions, this one rounds to nearest for visual reason.
// In case of a tie, display the dot at lower position of the graph,
// i.e. MSB of the "details" data.
double fraction = (1.0 - rem) * 8.0;
fraction -= (int)fraction;
double distance = (new->nCellsPainted - new->topPoint) * 8.0 + (1.0 - fraction) * 0.5;
double distance = ((double)(int)new->nCellsPainted - new->topPoint) * 8.0 + (1.0 - fraction) * 0.5;
blanksAtEnd = (uint8_t)distance;

// Tiebreaking direction that may be needed in the ASCII display mode.
Expand Down

0 comments on commit 6850aa3

Please sign in to comment.