Fix incorrect formatting of probabilities in the sidebar

This resulted from an incorrect use of std::setprecision, which sets the number of significant figures to display, not the number of decimal places.

(cherry-picked from commit 41e757be9f)
This commit is contained in:
Celtic Minstrel 2018-07-03 22:16:03 -04:00 committed by Charles Dang
parent a930dc28a9
commit 494ba287ec

View file

@ -843,9 +843,11 @@ static std::string format_prob(double prob)
{
if(prob > 0.9995) {
return "100%";
} else if(prob < 0.0005) {
return "0%";
}
std::ostringstream res;
res << std::setprecision(1) << std::setw(4) << 100.0 * prob << "%";
res << std::setprecision(prob < 0.1 ? 2 : 3) << 100.0 * prob << "%";
return res.str();
}