Fix rounding of percentage calculation
This commit is contained in:
parent
d6269952a6
commit
eee2e6172a
@ -284,7 +284,9 @@ class Terminal {
|
|||||||
const auto histogramSamples = Statistics::getHistogram(t);
|
const auto histogramSamples = Statistics::getHistogram(t);
|
||||||
m_serial.template txNumber<uint8_t, 10, 2>(t);
|
m_serial.template txNumber<uint8_t, 10, 2>(t);
|
||||||
m_serial << F(" C = ");
|
m_serial << F(" C = ");
|
||||||
m_serial.template txNumber<uint8_t, 10, 3, ' '>((histogramSamples * 100) / totalSamples);
|
const auto percent =
|
||||||
|
static_cast<uint8_t>((2 * 100 * histogramSamples + totalSamples) / (2 * totalSamples));
|
||||||
|
m_serial.template txNumber<uint8_t, 10, 3, ' '>(percent);
|
||||||
m_serial << F("%\t");
|
m_serial << F("%\t");
|
||||||
const auto normalizedSamples = static_cast<uint8_t>(histogramSamples / normalizationFactor);
|
const auto normalizedSamples = static_cast<uint8_t>(histogramSamples / normalizationFactor);
|
||||||
for (uint8_t i = 0; i < normalizedSamples; ++i) {
|
for (uint8_t i = 0; i < normalizedSamples; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user