/** copy the low-order bits of the argument into this BitVector and sign extend; returns <tt>this</tt> */
public BitVector setAndSignExtend(long value) {
if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector");
- for(int i=0; i<Math.min(length(), 64); i++)
- set(i, ((value >>> i) & 1L) != 0);
- if (value < 0)
- for(int i=64; i<length(); i++)
- set(i, true);
+ for(int i=0; i<length(); i++)
+ set(i, i<64 ? (((value >>> i) & 1L) != 0) : value<0 ? true : false);
return this;
}