bramstein / bit-array

JavaScript implementation of bit arrays.
78 stars 18 forks source link

Maybe i made a mistake #8

Closed grotaldo closed 10 years ago

grotaldo commented 10 years ago

But if i make something like :

var a = new BitArray(10); a.set(0, true); a.not();

console.log(a.count());

I got 31 as result instead of 9 is it ok ?

bramstein commented 10 years ago

Sorry for the late response. This is caused by the fact bit-array use 32bit numbers internally to store the bit array. So if you create a bit array size 10 it will round it up to 32 (or the next multiple of 32.) So yes, it is expected, but a little confusing. I'll think about clearing this up in the README, thanks for bringing it to my attention.