Skip to content

Commit

Permalink
fix frequency formatting when copying from frequency selector
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreRouma committed Oct 16, 2024
1 parent 1cbc8ec commit fbbafdd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/src/utils/hrfreq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ namespace hrfreq {
char numBuf[128];
int numLen = sprintf(numBuf, "%0.*lf", maxDecimals, freq);

// Remove the useless zeros
for (int i = numLen-1; i >= 0; i--) {
if (numBuf[i] != '0' && numBuf[i] != '.') { break; }
numBuf[i] = 0;
// If there is a decimal point, remove the useless zeros
if (maxDecimals) {
for (int i = numLen-1; i >= 0; i--) {
bool dot = (numBuf[i] == '.');
if (numBuf[i] != '0' && !dot) { break; }
numBuf[i] = 0;
if (dot) { break; }
}
}

// Concat the suffix
Expand Down

0 comments on commit fbbafdd

Please sign in to comment.