Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

One last fix for incorrectly type mask literals (32/64 bit issue).

  • Loading branch information...
commit e7587a0c10e057ab0bbcc9a895c71ee2e3d3f33e 1 parent f126713
@brendon9x brendon9x authored Tyler McMullen committed
Showing with 4 additions and 1 deletion.
  1. +1 −1  ext/bitset/bitset.c
  2. +3 −0  spec/bitset_spec.rb
View
2  ext/bitset/bitset.c
@@ -159,7 +159,7 @@ static VALUE rb_bitset_cardinality(VALUE self) {
for(i = 0; i < max; i++) {
uint64_t segment = bs->data[i];
if(i+1 == max)
- segment &= ((1 << (bs->len & 0x3F)) - 1);
+ segment &= ((((uint64_t) 1) << (bs->len & 0x3F)) - 1);
count += __builtin_popcountll(segment);
}
return INT2NUM(count);
View
3  spec/bitset_spec.rb
@@ -136,6 +136,9 @@
bs = Bitset.new(10_000)
bs.set(*(0...5000).to_a)
bs.cardinality.should == 5000
+
+ bs = Bitset.from_s "01001101000000000000000000000011000010100100000000000000010000101000000000000000100000000100000000000010100100010000000010000100000100000001001000110000000000100010000000010100000000000000110000000000000000000000000100000000100010010000000000000000000001000000000000000000000000000001000000000000000000000000000100000000010010000000000000000000100100000000000000001000000010000001000000000000001000001100010001000000000000001000001000001000000000000001100010000010010001000000010000100000000000110000"
+ bs.cardinality.should == 63
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.