Skip to content

Commit 48fc540

Browse files
committed
compatibility fix
1 parent e5612e9 commit 48fc540

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

include/fast_float/float_common.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,13 +1132,10 @@ template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
11321132

11331133
template <typename UC>
11341134
fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) {
1135+
// wchar_t and char can be signed, so we need to be careful.
11351136
using UnsignedUC = typename std::make_unsigned<UC>::type;
1136-
auto uc = static_cast<UnsignedUC>(c);
1137-
// For types larger than one byte, we need to force an index with sentinel
1138-
// value (using index zero because that is easiest) if any byte other than
1139-
// the low byte is non-zero.
1140-
auto mask = static_cast<UnsignedUC>(-((uc & ~0xFFull) == 0));
1141-
return int_luts<>::chdigit[static_cast<unsigned char>(uc & mask)];
1137+
return int_luts<>::chdigit[static_cast<unsigned char>(static_cast<UnsignedUC>(c)
1138+
& static_cast<UnsignedUC>(-((static_cast<UnsignedUC>(c) & ~0xFFull) == 0)))];
11421139
}
11431140

11441141
fastfloat_really_inline constexpr size_t max_digits_u64(int base) {

0 commit comments

Comments
 (0)