Results 1 to 6 of 6

Thread: What is use of Shift Left/Right?

  1. #1

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Question What is use of Shift Left/Right?

    I have been programmer for a long a time. I was also introduced about the shifting of bytes (left and right) a long time ago but never really used it.

    Can you guys give some application or usage of this? Thanks!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: What is use of Shift Left/Right?

    Moved from "Contest Entries" forum

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: What is use of Shift Left/Right?

    Shift left is * 2. Shift right is /2. And that's only a trivial usage. You can shift bits into a byte from a bit-banger (single bit) port to receive serial data. There are probably about another hundred uses I just can't think of at the moment.

  4. #4

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Talking Re: What is use of Shift Left/Right?

    Quote Originally Posted by si_the_geek
    Moved from "Contest Entries" forum
    Sorry about that... Hehe. Just a miscommunication with my mouse..

  5. #5

    Thread Starter
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Thumbs up Re: What is use of Shift Left/Right?

    Quote Originally Posted by Al42
    Shift left is * 2. Shift right is /2. And that's only a trivial usage. You can shift bits into a byte from a bit-banger (single bit) port to receive serial data. There are probably about another hundred uses I just can't think of at the moment.
    Thanks for the answer! At least it's a start. Please post again if you have thought of more.. Thanks again!

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: What is use of Shift Left/Right?

    Compound integers:

    high byte to byte: (byte) short >> 8

    two bytes to short:
    (short) = (highByte << 8) & lowByte

    Etc.

Posting Permissions

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



Click Here to Expand Forum to Full Width