Skip to content

Commit

Permalink
Fixes #783 and reverts to unsigned FLINT_BIT_COUNT.
Browse files Browse the repository at this point in the history
  • Loading branch information
wbhart committed Jul 7, 2020
1 parent c8ff8a3 commit 5010d74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flint.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,13 @@ typedef __mpfr_struct flint_mpfr;
FLINT_DLL extern const unsigned char __flint_clz_tab[128];
#endif

/* Beware when using the unsigned return value in signed arithmetic */
static __inline__
slong FLINT_BIT_COUNT(mp_limb_t x)
mp_limb_t FLINT_BIT_COUNT(mp_limb_t x)
{
mp_limb_t zeros = FLINT_BITS;
if (x) count_leading_zeros(zeros, x);
return (slong) (FLINT_BITS - zeros);
return FLINT_BITS - zeros;
}

#define FLINT_FLOG2(k) (FLINT_BIT_COUNT(k) - 1)
Expand Down
2 changes: 1 addition & 1 deletion fmpz_mat/next_col_van_hoeij.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int fmpz_mat_next_col_van_hoeij(fmpz_mat_t M, fmpz_t P,
k = fmpz_bits(P) - bit_r - bit_r/2;

/* check if LLL justified */
if (k < exp + FLINT_BIT_COUNT(r + 1))
if (k < exp + (slong) FLINT_BIT_COUNT(r + 1))
return 0;

fmpz_init(P_trunc);
Expand Down

0 comments on commit 5010d74

Please sign in to comment.