Thread overview
bit array's size
Dec 03, 2003
Y.Tomino
Dec 03, 2003
Walter
Dec 04, 2003
Y.Tomino
Dec 04, 2003
Sean L. Palmer
December 03, 2003
Hello.

It was written on the document that "on Intel CPUs it would be rounded up to
the next 32 bit size. ".
bit[1] .. bit[32] should be 4 byte. Is that bug ?

int main()
{
 bit[8] a8;
 printf("%d\n", a8.size); //4 ok
 bit[16] a16;
 printf("%d\n", a16.size); //5
 bit[32] a32;
 printf("%d\n", a32.size); //7
 bit[256] a256;
 printf("%d\n", a256.size); //35 (256/8 = 32)
 return 0;
}

And, I want to use "&" "|" "^" "!" operators for bit array like Pascal's
Set.
bit[8] a = [3:1, 4:1];
bit[8] b = [4:1, 5:1];
a[] & b[] = [4:1]
a[] | b[] = [3:1, 4:1, 5:1]
a[] ^ b[] = [3:1, 5:1]
!a[] = [0:1, 1:1, 2:1, 5:1, 6:1, 7:1]

YT

December 03, 2003
"Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bqjeh3$lmb$1@digitaldaemon.com...
> Hello.
>
> It was written on the document that "on Intel CPUs it would be rounded up
to
> the next 32 bit size. ".
> bit[1] .. bit[32] should be 4 byte. Is that bug ?
>
> int main()
> {
>  bit[8] a8;
>  printf("%d\n", a8.size); //4 ok
>  bit[16] a16;
>  printf("%d\n", a16.size); //5
>  bit[32] a32;
>  printf("%d\n", a32.size); //7
>  bit[256] a256;
>  printf("%d\n", a256.size); //35 (256/8 = 32)
>  return 0;
> }

That looks like a bug. The results should be 4,4,4,32.

>
> And, I want to use "&" "|" "^" "!" operators for bit array like Pascal's
> Set.
> bit[8] a = [3:1, 4:1];
> bit[8] b = [4:1, 5:1];
> a[] & b[] = [4:1]
> a[] | b[] = [3:1, 4:1, 5:1]
> a[] ^ b[] = [3:1, 5:1]
> !a[] = [0:1, 1:1, 2:1, 5:1, 6:1, 7:1]

That's supposed to work, but I haven't implemented it yet.


December 04, 2003
Thanks!
I'm waiting for correcting these.

I'll use fixed-length bit array as set of flags like window styles (case
where unsigned int is used at C),
or bit[255] as cache of IsLeadBytes or ...
It will be powerful tool.

YT

"Walter" <walter@digitalmars.com> wrote in message news:bqlmp5$upi$1@digitaldaemon.com...
>
> "Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bqjeh3$lmb$1@digitaldaemon.com...
> > Hello.
> >
> > It was written on the document that "on Intel CPUs it would be rounded
up
> to
> > the next 32 bit size. ".
> > bit[1] .. bit[32] should be 4 byte. Is that bug ?
> >
> > int main()
> > {
> >  bit[8] a8;
> >  printf("%d\n", a8.size); //4 ok
> >  bit[16] a16;
> >  printf("%d\n", a16.size); //5
> >  bit[32] a32;
> >  printf("%d\n", a32.size); //7
> >  bit[256] a256;
> >  printf("%d\n", a256.size); //35 (256/8 = 32)
> >  return 0;
> > }
>
> That looks like a bug. The results should be 4,4,4,32.
>
> >
> > And, I want to use "&" "|" "^" "!" operators for bit array like Pascal's
> > Set.
> > bit[8] a = [3:1, 4:1];
> > bit[8] b = [4:1, 5:1];
> > a[] & b[] = [4:1]
> > a[] | b[] = [3:1, 4:1, 5:1]
> > a[] ^ b[] = [3:1, 5:1]
> > !a[] = [0:1, 1:1, 2:1, 5:1, 6:1, 7:1]
>
> That's supposed to work, but I haven't implemented it yet.
>
>

December 04, 2003
I would not want it to be limited to 256 bits though.  I would want to be able to make associative arrays of bit.

And I *still* want to be able to convert bit array slices into integers, and integers into bit array slices.  That would eliminate the need for bitfields altogether, I think.  There's a whole thread on this somewhere on this NG.

Sean

"Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bqn8c3$76r$1@digitaldaemon.com...
> Thanks!
> I'm waiting for correcting these.
>
> I'll use fixed-length bit array as set of flags like window styles (case
> where unsigned int is used at C),
> or bit[255] as cache of IsLeadBytes or ...
> It will be powerful tool.
>
> YT
>
> "Walter" <walter@digitalmars.com> wrote in message news:bqlmp5$upi$1@digitaldaemon.com...
> >
> > "Y.Tomino" <demoonlit@inter7.jp> wrote in message news:bqjeh3$lmb$1@digitaldaemon.com...
> > > Hello.
> > >
> > > It was written on the document that "on Intel CPUs it would be rounded
> up
> > to
> > > the next 32 bit size. ".
> > > bit[1] .. bit[32] should be 4 byte. Is that bug ?
> > >
> > > int main()
> > > {
> > >  bit[8] a8;
> > >  printf("%d\n", a8.size); //4 ok
> > >  bit[16] a16;
> > >  printf("%d\n", a16.size); //5
> > >  bit[32] a32;
> > >  printf("%d\n", a32.size); //7
> > >  bit[256] a256;
> > >  printf("%d\n", a256.size); //35 (256/8 = 32)
> > >  return 0;
> > > }
> >
> > That looks like a bug. The results should be 4,4,4,32.
> >
> > >
> > > And, I want to use "&" "|" "^" "!" operators for bit array like
Pascal's
> > > Set.
> > > bit[8] a = [3:1, 4:1];
> > > bit[8] b = [4:1, 5:1];
> > > a[] & b[] = [4:1]
> > > a[] | b[] = [3:1, 4:1, 5:1]
> > > a[] ^ b[] = [3:1, 5:1]
> > > !a[] = [0:1, 1:1, 2:1, 5:1, 6:1, 7:1]
> >
> > That's supposed to work, but I haven't implemented it yet.