Thread: spliting 16bit variable into LSB and MSB 8 bit variables

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    spliting 16bit variable into LSB and MSB 8 bit variables

    Is there an easier / more efficient way to create an 8bit MSB and LSB pair from a 16bit variable than bit shifting and storing?

    Thanks
    ~Tim

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    34,310
    That is the easy way.
    And most modern processors achieve it in a single clock tick.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    2
    Quote Originally Posted by Salem View Post
    That is the easy way.
    And most modern processors achieve it in a single clock tick.
    Okay.. Thanks..

    ~T|/\/\

Popular pages Recent additions subscribe to a feed