> > bool negative; > > > > /* Truncate value to decr_width and sign extend for simplicity */ > > - value &= ((1ULL << nr_bits) - 1); > > + value &= MAKE_64BIT_MASK(0, nr_bits); > > What about: > > value = extract64(value, 0, nr_bits); > if (value != sextract64(value, 0, nr_bits)) { ...
Or: value = extract64(value, 0, nr_bits); value = ((target_long)value << (64 - nr_bits)) >> (64 - nr_bits); Also avoiding the problem with an invalid 64-bit shift with: > > value |= (0xFFFFFFFFULL << nr_bits); -- Luis Pires Instituto de Pesquisas ELDORADO Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>