Skip to content

Commit 6927483

Browse files
authored
Change check for "shift > Type::BITS" to avoid offset greater than total bits. (#133016)
nexttowardf16_test is resulting in calling shift and for some reason not meeting the invariant where offset is less than bits. Change the if statement to directly check if shift - 1 meets the conditions.
1 parent 4125054 commit 6927483

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/src/__support/FPUtil/dyadic_float.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ template <size_t Bits> struct DyadicFloat {
335335
.get_val();
336336

337337
MantissaType round_mask =
338-
shift > MantissaType::BITS ? 0 : MantissaType(1) << (shift - 1);
338+
shift - 1 >= MantissaType::BITS ? 0 : MantissaType(1) << (shift - 1);
339339
MantissaType sticky_mask = round_mask - MantissaType(1);
340340

341341
bool round_bit = !(mantissa & round_mask).is_zero();

0 commit comments

Comments
 (0)