We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fbf7cf1 commit 328648cCopy full SHA for 328648c
libc/src/__support/fixed_point/fx_bits.h
@@ -166,12 +166,11 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
166
// (u)?int_fx_t --> Fixed point
167
template <typename T, typename XType> LIBC_INLINE constexpr T fxbits(XType x) {
168
using FXRep = FXRep<T>;
169
-
170
// Shift number by FX_IBITS so the bits are in the right spot.
171
// If the number is negative we need to make it positive, shift it and then
172
// renegate it to get the correct value.
173
if (cpp::is_signed_v<XType> &&
174
- ((1 << (FXRep::TOTAL_LEN - 1)) & x)) {
+ (x >> (FXRep::TOTAL_LEN - FXRep::SIGN_LEN))) {
175
x = -x;
176
x >>= FXRep::INTEGRAL_LEN;
177
0 commit comments