title: Porting Bitwise Operations from C# To C
body: <p>I need some help porting this C# code over to C. I have it working in C# just fine but I'm getting the wrong return in C. Should I be breaking down the bit shifting into separate lines? I thought I had an issue with the data types but I think I have the right ones. Here was the working code that returns 0x03046ABE</p>
  
  <pre><code>  UInt32 goHigh(UInt32 x) { return (UInt32)(x &amp; 0xFFFF0000); }          
    UInt32 goLow(UInt32 x) { return (UInt32)(x &amp; 0xFFFF); } 
  
    UInt32 magic(UInt32 pass){
        UInt32 key = pass;
        UInt16 num = 0x0563;
        key = (goLow(key) &lt;&lt; 16) | (UInt16)(((num &gt;&gt; 3) | (num &lt;&lt; 13)) ^ (goHigh(key) &gt;&gt; 16));
        return key; //returns 0x03046ABE
  
     }
  
    magic(0x01020304);
  </code></pre>
  
  <p>This was the incorrect C code that I'm trying to get working</p>
  
  <pre><code>  unsigned long  goHigh(unsigned long  x) { 
           return (unsigned long )(x &amp; 0xFFFF0000); }          
    unsigned long  goLow(unsigned long  x) { 
           return (unsigned long )(x &amp; 0xFFFF); } 
  
    unsigned long  magic(unsigned long  pass){
        unsigned long key = pass;
        unsigned int num = 0x0563;
        key = (goLow(key) &lt;&lt; 16) | (unsigned int)(((num &gt;&gt; 3) | (num &lt;&lt; 13)) ^ (goHigh(key) &gt;&gt; 16));
        return key;
    }
  
    magic(0x01020304); //returns 0xb8c6a8e
  </code></pre>