Problem with bits in byte array....


Results 1 to 16 of 16

Threaded View

  1. #14
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Problem with bits in byte array....

    Hi Don,
    Thanks for that. I've tried to figure your code out without much luck, that visual representation helps me understand how you intend it to work. First I got thrown off by the arrays not being indexed from 0 and I thoght that was by intention (some trick) to make it work but now I'm not sure and I have to ask if you tried it?

    If I load arr1 with 77,97,110 I expect to get 19,22,5,46 (taken from Wikipedias example) but instead I get 19,0,4,0.

    The reason, I think, is that you're trying to load two bytes from the array into one word in one go with w1=arr1[1] etc.

    /Henrik.

    EDIT: It's not near as small as yours but this works for me:
    Code:
        Out[0] = ((In[0] >> 2) & 63)
        Out[1] = ((In[0] & 3) << 4) + ((In[1] & 240) >> 4) & 63
        Out[2] = ((In[1] & 15) << 2) + ((In[2] & 192) >> 6) & 63
        Out[3] = (In[2] & 63)
    Last edited by HenrikOlsson; - 18th October 2011 at 20:47.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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