converting bits sequence into binary or string
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: converting bits sequence into binary or string

  1. #1
    Join Date
    Apr 2014
    Posts
    6

    converting bits sequence into binary or string

    I have stored six different bits into my SQL Server database and now I want to combine that all into ASCII or otherwise in string to send on serial port. so, how could I?

    my 6 different bits stored into database in six different field name as v1,...., v6. and its in format of bit.

  2. #2
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    217

    Re: converting bits sequence into binary or string

    You could try the System.Collections.BitArray class and its Cast<> method.

  3. #3
    Join Date
    Apr 2014
    Location
    in northeast ohio
    Posts
    69

    Re: converting bits sequence into binary or string

    i on the sql portion no comment, as for the bits to ascii
    you would could use bit math

    turn the bits into a byte ...n , then
    cast that byte to char c = (char)n;
    though its been a minute this may not be exact
    something akin to or-ing each flag to a position in a byte
    byte n = 0;
    n = n | bitflag05 << 5 ;
    char c = (char)n;
    to read it cast the char back to a byte then by and-ing &
    if( n & ( (byte)1 << 5 ) > 0 ) { }
    ...
    you would google for a tutorial on bit shifting and bit math operators for this part

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center