Thread: 2 uint8_t to a uint16?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    58

    Question 2 uint8_t to a uint16?

    Hi

    I'm looking for a way to take two uint8_t values and place them in a Uint16_t...

    Code:
    uint8_t bob 0xDD;
    uint8_t fred 0xFF;
    
    uint16_t tom;
    
    tom = ???
    The end result being:

    Tom: 0xDDFF

    Has any one got any ideas?

    Cheers

    David

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    tom = bob;
    tom <<= 8;
    tom |= fred ;
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. concatenating two bytes into an uint16
    By davo666 in forum C Programming
    Replies: 11
    Last Post: 01-07-2009, 11:43 PM
  2. Kind Soul Needed: Help with Pointer Code Cleanup
    By gmrobert in forum C Programming
    Replies: 5
    Last Post: 08-30-2007, 09:15 AM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM