Skip to content

Commit

Permalink
fix implicit conversion to floating-point in F14TestUtil
Browse files Browse the repository at this point in the history
Summary:
Addresses this warning under MSVC:
```
folly/container/test/F14TestUtil.h(48): warning C5219: implicit conversion from 'size_t' to 'double', possible loss of data
```

Reviewed By: ilvokhin

Differential Revision: D67658094

fbshipit-source-id: 4d6b8563c1f354337da7e6e20956bc22c4ce692b
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jan 2, 2025
1 parent 3a49ba5 commit 25759e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion folly/container/test/F14TestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ inline std::ostream& operator<<(std::ostream& xo, Histo const& histo) {
for (auto v : histo.data) {
sum += v;
}
auto const dsum = static_cast<double>(sum);
size_t partial = 0;
for (size_t i = 0; i < histo.data.size(); ++i) {
if (i > 0) {
Expand All @@ -45,7 +46,7 @@ inline std::ostream& operator<<(std::ostream& xo, Histo const& histo) {
partial += histo.data[i];
if (histo.data[i] > 0) {
xo << i << ": " << histo.data[i] << " ("
<< (static_cast<double>(partial) * 100.0 / sum) << "%)";
<< (static_cast<double>(partial) * 100.0 / dsum) << "%)";
}
}
xo << "]";
Expand Down

0 comments on commit 25759e9

Please sign in to comment.