Home All Groups Group Topic Archive Search About

converting bitarray to int64

Author
15 Jan 2007 1:07 PM
vidishasharma
I have a bitarray with values as {true,false,true,true}

I want to convert this bitarray to   Int64. How can I do the same,

when I take
byte[] testbytes = new byte[bit1.Length];
bit1.CopyTo(testbytes, 0)

where bit1 is my bit array
I get everything as zero

When I take
bool[] testbytesbool = new bool[bit1.Length];
bit1.CopyTo(testbytesbool , 0)

I get true and false at proper places.However this is not geting
converted to in64.

How do I conver this to in64.

This is just an example as my bitarry is comprised of 200000 values.
therefore I want to convert it to int64.

Author
15 Jan 2007 4:54 PM
Fabio Z
<vidishasha***@gmail.com> ha scritto nel messaggio

Show quoteHide quote
>I have a bitarray with values as {true,false,true,true}
>
> I want to convert this bitarray to   Int64. How can I do the same,
>
> when I take
> byte[] testbytes = new byte[bit1.Length];
> bit1.CopyTo(testbytes, 0)
>
> where bit1 is my bit array
> I get everything as zero
>
> When I take
> bool[] testbytesbool = new bool[bit1.Length];
> bit1.CopyTo(testbytesbool , 0)
>
> I get true and false at proper places.However this is not geting
> converted to in64.
>
> How do I conver this to in64.

Use the BitConverter class :)

Author
16 Jan 2007 4:32 AM
vidishasharma
I am unable to use the same.

Can you give an example. to convert bool[] to in32 or int 64