Skip to content

Commit

Permalink
Suppress an msvc warning
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 16, 2022
1 parent deeab54 commit 91abfcd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,7 @@ FMT_CONSTEXPR20 inline void format_dragon(basic_fp<uint128_t> value,
upper = &upper_store;
}
}
bool even = (value.f & 1) == 0;
int even = static_cast<int>(value.f & 1);

This comment has been minimized.

Copy link
@dimztimz

dimztimz Jul 18, 2022

Contributor

This change does not look like it is equivalent. It looks like your are now checking for odd instead of even number.

This comment has been minimized.

Copy link
@phprus

phprus Jul 18, 2022

Contributor

@vitaut
Yes, this is an inverted condition.

Suggestion:

int even = 1 - static_cast<int>(value.f & 1);

Since value.f & 1 by definition 0 or 1.

This comment has been minimized.

Copy link
@vitaut

vitaut Jul 19, 2022

Author Contributor

Good catch, thanks! Fixed in 371f9c7 (I went with just adding cast to the old expression for simplicity). We definitely need a test case for this =).

if (!upper) upper = &lower;
if ((flags & dragon::fixup) != 0) {
if (add_compare(numerator, *upper, denominator) + even <= 0) {
Expand Down

0 comments on commit 91abfcd

Please sign in to comment.