Skip to content

Commit

Permalink
Fix Wconversion warns: static casting doubles
Browse files Browse the repository at this point in the history
Signed-off-by: Melvin He <[email protected]>
  • Loading branch information
melvinhe committed Mar 14, 2024
1 parent 2860105 commit 43367d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/groups/mwc/mwcu/mwcu_printutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ prettyBytes(bsl::ostream& stream, bsls::Types::Int64 bytes, int precision)
if (precision == 0 || unit == 0) {
// When no decimal part is required, we round up the value and print it
bsls::Types::Int64 quot = lround(
static_cast<double>(bytes) / bsl::pow(1024., static_cast<double>(unit)));
static_cast<double>(bytes) /
bsl::pow(1024., static_cast<double>(unit)));
if (quot == 1024 && unit != k_UNITS_COUNT - 1) {
// This is a special case when the round up leads to the next unit
quot = 1;
Expand Down Expand Up @@ -281,7 +282,8 @@ bsl::ostream& prettyTimeInterval(bsl::ostream& stream,
// precision digits
const bsls::Types::Int64 quot = timeNs / div;
const long remainder = lround(
(static_cast<double>(timeNs - quot * div) / static_cast<double>(div)) *
(static_cast<double>(timeNs - quot * div) /
static_cast<double>(div)) *
bsl::pow(10., static_cast<double>(precision)));
temp << quot << "." << bsl::setw(precision) << bsl::setfill('0')
<< remainder;
Expand Down

0 comments on commit 43367d6

Please sign in to comment.