Converting Base 2 Numbers to Base 10

  • Thread starter Thread starter Phil Galey
  • Start date Start date
P

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?
 
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" <[email protected]> escribió en el mensaje 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?
 
Great. Thank you.


"José Manuel Agüero" <chema012 en hotmail.com> wrote in message
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" <[email protected]> escribió en el mensaje
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?
 
Back
Top