Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'Wconversion' warns: static casting doubles #214

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 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(
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 @@ -272,7 +273,7 @@ bsl::ostream& prettyTimeInterval(bsl::ostream& stream,
// Compute and print the quotient and remainder
if (precision == 0 || unitIdx == 0) {
// When no decimal part is required, we round up the value and print it
const bsls::Types::Int64 quot = lround(timeNs /
const bsls::Types::Int64 quot = lround(static_cast<double>(timeNs) /
static_cast<double>(div));
temp << quot;
}
Expand All @@ -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) / 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
Loading