How to do bitwise shift across several variables/array members?


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: How to do bitwise shift across several variables/array members?

    I'm thinking it in the following way (as example, 2 byte array, shifted to right)

    1. Read both array bytes into variables A and B
    2. Shift B right 1 bit
    3. Add LSB from A as MSB to B
    4. Shift A right
    5. Write A and B back to array

    Repeat as desired.


    Correct?

  2. #2
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: How to do bitwise shift across several variables/array members?

    Yes, assuming you really do want a shift and don't want to rotate the value shifted out of B back into the MSB of the array.
    There's no need to copy the array bytes to A and B, but if it helps you keep it straight then go for it.

Similar Threads

  1. SWAP COMMAND extended to Longs and array variables
    By longpole001 in forum PBP Wish List
    Replies: 1
    Last Post: - 9th April 2018, 23:41
  2. MIBAM and Array Variables in FOR-NEXT Loops
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th August 2010, 12:50
  3. Seeting array variables in For-Next loop
    By bcd in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th October 2007, 07:01
  4. Reading Array values into variables
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 21st March 2005, 10:30
  5. List of Members
    By NavMicroSystems in forum Forum Requests
    Replies: 5
    Last Post: - 17th January 2005, 17:10

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