BitArray padding with zeros


#1

i can’t get the BitArray toString method to pad my output to always 8bits ( i want to display uint8 values), is thhe second parameter working in some other way ?

[code]
for (int i=0; i<255; i++)
{
BitArray b((const int)i);
Log (T(“val=”) + String(i) + T(" bits=[") + b.toString (2,8) + T("]"));
}

[code]

and the result is:

val=0 bits=[00000000]
val=1 bits=[0000000]
val=2 bits=[000000]
val=3 bits=[000000]
val=4 bits=[00000]
val=5 bits=[00000]
val=6 bits=[00000]
val=7 bits=[00000]
val=8 bits=[0000]
val=9 bits=[0000]
val=10 bits=[0000]
val=11 bits=[0000]
val=12 bits=[0000]
val=13 bits=[0000]
val=14 bits=[0000]
val=15 bits=[0000]
val=16 bits=[000]
val=17 bits=[000]
val=18 bits=[000]
val=19 bits=[000]
val=20 bits=[000]
val=21 bits=[000]
val=22 bits=[000]
val=23 bits=[000]
val=24 bits=[000]
val=25 bits=[000]
val=26 bits=[000]
val=27 bits=[000]
val=28 bits=[000]
val=29 bits=[000]
val=30 bits=[000]
val=31 bits=[000]
val=32 bits=[00]
val=33 bits=[00]
..................
val=128 bits=[10000000]
val=129 bits=[10000001]
val=130 bits=[10000010]
val=131 bits=[10000011]
val=132 bits=[10000100]
val=133 bits=[10000101]
val=134 bits=[10000110]
val=135 bits=[10000111]
val=136 bits=[10001000]
val=137 bits=[10001001]
val=138 bits=[10001010]
val=139 bits=[10001011]
val=140 bits=[10001100]
val=141 bits=[10001101]
val=142 bits=[10001110]
val=143 bits=[10001111]
val=144 bits=[10010000]
val=145 bits=[10010001]
val=146 bits=[10010010]
val=147 bits=[10010011]
val=148 bits=[10010100]

#2

Sorry - looks like there’s a ridiculously stupid typo in that method. Will fix it immediately!


#3