Sep 13, 2005 #1 japhy Programmer Joined Sep 27, 2004 Messages 12 Location US Probably a very easy question...thanks for your patience in answering it. I'm trying to combine two 16 bit words into 1 32 bit DWORD...the two 16 bit words are contained in unsigned ints. which operator can combine these in this way? Thanks very much
Probably a very easy question...thanks for your patience in answering it. I'm trying to combine two 16 bit words into 1 32 bit DWORD...the two 16 bit words are contained in unsigned ints. which operator can combine these in this way? Thanks very much
Sep 13, 2005 1 #2 cpjust Programmer Joined Sep 23, 2003 Messages 2,132 Location US If you want them side by side, you need to use the left shift operator on one of them. Ex. Code: unsigned short one = 0x1234; unsigned short two = 0x5678; unsigned int combined = (one << 16) | two; // Now combined is 0x12345678. Upvote 0 Downvote
If you want them side by side, you need to use the left shift operator on one of them. Ex. Code: unsigned short one = 0x1234; unsigned short two = 0x5678; unsigned int combined = (one << 16) | two; // Now combined is 0x12345678.
Sep 13, 2005 1 #3 JJM11 Programmer Joined Sep 9, 2005 Messages 5 Location ES Option 2: WORD one=0x1234; WORD two=0x5678; DWORD three; HIWORD(three)=one; LOWORD(three)=two; result -> 0x12345678 Upvote 0 Downvote
Option 2: WORD one=0x1234; WORD two=0x5678; DWORD three; HIWORD(three)=one; LOWORD(three)=two; result -> 0x12345678