When freq was changed to be an integer, the conversion to kHz became a
truncation. Divide by the float 1000.0 to pass the correct value to the
stringstream formatting routine.
std::stringstream ss;
ss << std::fixed;
if (freq >= 10000) {
- ss << std::setprecision (1) << freq / 1000 << "kHz";
+ ss << std::setprecision (1) << freq / 1000.0 << "kHz";
} else if (freq >= 1000) {
- ss << std::setprecision (2) << freq / 1000 << "kHz";
+ ss << std::setprecision (2) << freq / 1000.0 << "kHz";
} else {
ss << std::setprecision (0) << freq << "Hz";
}