fix ftruncf changes 1.0000000 to 0.99990004

This commit is contained in:
Chris Danford
2005-03-21 11:22:20 +00:00
parent 1d1a6a95ac
commit f4d1dfc8cf
+5
View File
@@ -97,6 +97,11 @@ void PercentageDisplay::Refresh()
// TRICKY: printf will round, but we want to truncate. Otherwise, we may display a percent
// score that's too high and doesn't match up with the calculated grade.
float fTruncInterval = powf(0.1f, (float) PERCENT_TOTAL_SIZE-1);
// TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost to
// fPercentDancePoints to correct for this.
fPercentDancePoints += 0.000001f;
fPercentDancePoints = ftruncf( fPercentDancePoints, fTruncInterval );
sNumToDisplay = ssprintf( "%*.*f%%", (int) PERCENT_TOTAL_SIZE, (int) PERCENT_DECIMAL_PLACES, fPercentDancePoints*100 );