working with bits

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • s gall

    working with bits

    Hi all
    I have a task to test a checksum algrorithum. This requires changing a
    string of 12 chr's to a stream of 96 bits and then manipulating these.
    Currently I work in vb (vb2008). Would it be better for me to use another
    language (say vc++) and build a DLL to do the bit manipulating or does
    vb.net have some way of working with bits.

    Stephen

  • Gillard

    #2
    Re: working with bits

    if the manipulation is easy to do there is a converter from decimal to
    binary

    Public Function DecToBin(ByVal DecVal As Double) As String
    Dim a As Double
    a = DecVal
    For b = 1 To Int(Log(DecVal) / Log(2)) + 1
    DecToBin = CDbl(a Mod 2) & DecToBin
    a = CDbl(Int(a / 2))
    Next b
    End Function


    "s gall" <s@none.co.nzwr ote in message
    news:2E100867-0DB0-474C-ABEA-CA734359DEC0@mi crosoft.com...
    Hi all
    I have a task to test a checksum algrorithum. This requires changing a
    string of 12 chr's to a stream of 96 bits and then manipulating these.
    Currently I work in vb (vb2008). Would it be better for me to use another
    language (say vc++) and build a DLL to do the bit manipulating or does
    vb.net have some way of working with bits.
    >
    Stephen

    Comment

    • Bill McCarthy

      #3
      Re: working with bits

      Hi Stephen,

      VB supports the standard bitwise operations Or, And, Not and XOr as well as
      bit shifting >for right shift, and << for left shift.
      One thing to be aware of, there is no type character for byte, so for
      constants you have to write CByte(&HFF) or similar.
      You can get the string into an array of bytes like so:

      Dim b(0 To 7) As Byte
      For i As Int32 = 0 To 7
      b(i) = CByte(Asc(keySt ring(i)) And &H80)
      Next



      "s gall" <s@none.co.nzwr ote in message
      news:2E100867-0DB0-474C-ABEA-CA734359DEC0@mi crosoft.com...
      Hi all
      I have a task to test a checksum algrorithum. This requires changing a
      string of 12 chr's to a stream of 96 bits and then manipulating these.
      Currently I work in vb (vb2008). Would it be better for me to use another
      language (say vc++) and build a DLL to do the bit manipulating or does
      vb.net have some way of working with bits.
      >
      Stephen

      Comment

      Working...