Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify by-hand rounded %0.1f formatting
Coverity is rightly pointing out that it is not clear that `double` math is wanted, where the conversion from `long long` to `double` should occur, and where integer remainders are discarded. Most compilers will get it right, but humans may find it confusing or unexpected. * Did some algebra to reduce half-bit errors. * Added a cast to make the conversion explicit. * Aligned turn expected damage with running expected damage so both are the same representation. Closes CID 1380164
- Loading branch information
1 parent
28cfa72
commit 520e617
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ void statistics_dialog::add_damage_row( | |
|
||
std::ostringstream str; | ||
str << damage << " / " | ||
<< (expected * 10 + shift / 2) / shift * 0.1 | ||
<< static_cast<double>(((expected * 20) + shift) / (2 * shift)) * 0.1 | ||
<< " " // TODO: should probably make this two columns | ||
<< ((dsa < 0) ^ (expected < 0) ? "" : "+") | ||
<< (expected == 0 ? 0 : 100 * dsa / expected) << '%'; | ||
|
@@ -157,7 +157,7 @@ void statistics_dialog::add_damage_row( | |
|
||
if(show_this_turn) { | ||
str << turn_damage << " / " | ||
<< (turn_expected * 10 + shift / 2) / shift / 10 | ||
<< static_cast<double>(((turn_expected * 20) + shift) / (2 * shift)) * 0.1 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
GregoryLundberg
Author
Contributor
|
||
<< " " // TODO: should probably make this two columns | ||
<< ((dst < 0) ^ (turn_expected < 0) ? "" : "+") | ||
<< (turn_expected == 0 ? 0 : 100 * dst / turn_expected) << '%'; | ||
|
For the record, I had already fixed the warning in this line (as there weren't any floating-point numbers left, see 670bcf7#diff-7c7efbed9f4ea67ab046385d27aa6d49)