Skip to content

Commit 328648c

Browse files
author
smallp-o-p
committed
Fix shift overflow compile error
1 parent fbf7cf1 commit 328648c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

libc/src/__support/fixed_point/fx_bits.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
166166
// (u)?int_fx_t --> Fixed point
167167
template <typename T, typename XType> LIBC_INLINE constexpr T fxbits(XType x) {
168168
using FXRep = FXRep<T>;
169-
170169
// Shift number by FX_IBITS so the bits are in the right spot.
171170
// If the number is negative we need to make it positive, shift it and then
172171
// renegate it to get the correct value.
173172
if (cpp::is_signed_v<XType> &&
174-
((1 << (FXRep::TOTAL_LEN - 1)) & x)) {
173+
(x >> (FXRep::TOTAL_LEN - FXRep::SIGN_LEN))) {
175174
x = -x;
176175
x >>= FXRep::INTEGRAL_LEN;
177176
x = -x;

0 commit comments

Comments
 (0)