Home All Groups Group Topic Archive Search About

Converting Base 2 Numbers to Base 10

Author
15 Mar 2006 10:30 PM
Phil Galey
Is it possible to convert from a BitArray to its Base 10 counterpart?

So if you have

Dim x As New BitArray(New Integer() {1, 0, 1})

Then how can you get to 5 from x being 101?

Author
15 Mar 2006 11:17 PM
José_Manuel_Agüero
Hello Phil,

Try this:

Dim a(3) As Byte

Dim x As New BitArray(New Boolean() {True, False, True})

x.CopyTo(a, 0) 'x.Length must be between 0 and 32.

MsgBox(BitConverter.ToInt32(a, 0))



Regards.





"Phil Galey" <paga***@starcalif.com.nospam> escribió en el mensaje news:eWG0hAISGHA.1844@TK2MSFTNGP12.phx.gbl...
Is it possible to convert from a BitArray to its Base 10 counterpart?

So if you have

Dim x As New BitArray(New Integer() {1, 0, 1})

Then how can you get to 5 from x being 101?
Author
15 Mar 2006 11:31 PM
Phil Galey
Great.  Thank you.


"José Manuel Agüero" <chema012 en hotmail.com> wrote in message
news:#CtAfaISGHA.1688@TK2MSFTNGP11.phx.gbl...
Hello Phil,

Try this:

Dim a(3) As Byte

Dim x As New BitArray(New Boolean() {True, False, True})

x.CopyTo(a, 0) 'x.Length must be between 0 and 32.

MsgBox(BitConverter.ToInt32(a, 0))



Regards.





"Phil Galey" <paga***@starcalif.com.nospam> escribió en el mensaje
news:eWG0hAISGHA.1844@TK2MSFTNGP12.phx.gbl...
Is it possible to convert from a BitArray to its Base 10 counterpart?

So if you have

Dim x As New BitArray(New Integer() {1, 0, 1})

Then how can you get to 5 from x being 101?