FromInteger Construction
CMCDragonkai opened this issue · comments
How come fromInteger doesn't do anything except create a bitarray with integer as the size? I thought have thought it would be equivalent to a decbin
style construction. That is fromInteger(2) should give back the bitarray 10
and fromInteger(4) should give 100
... etc.
Would be great if it has a size designation as well, so one could easily create constants representing options in classes like:
class A {
const ERROR_A = BitArray::fromInteger(1, 4);
const ERROR_B = BitArray::fromInteger(2, 4);
const ERROR_C = BitArray::fromInteger(4, 4);
const ERROR_D = BitArray::fromInteger(8, 4);
}
Although the above seems a bit verbose. I currently just rely on the normal PHP ints.
It's difficult now to change the API, what do you think to create instead a
BitArray::fromBits(int, size)
method?
Yea that might be right. But fromBits
seems wrong. What about fromDec
?
Good idea, will change that in september (currently on holydays...)
Fixed in 1.2.0