title: set 4-bit nibble in an int type
body: <p>we need to come up a method that set a 4-bit nibbles in an int
  output should like this:</p>
  
  <pre><code> setNibble(0xAAA5, 0x1, 0); // =&gt; 0xAAA1
   setNibble(0x56B2, 0xF, 3); // =&gt; 0xF6B2
  </code></pre>
  
  <p>This is what i wrote...</p>
  
  <p>but there have something wrong that I cannot figure out</p>
  
  <pre><code>setNibble(FFFF, 0, 0): Expected: FFF0 Result: FF00 
  setNibble(FFFF, 6, 1): Expected: FF6F Result:  6FF 
  setNibble(1312, E, 1): Expected: 13E2 Result:  E12 
  </code></pre>
  
  <p>update: I already put down the code just incase. but basically the answer is really clear and there are so many great answer above. </p>