title: How to modify bits in an integer?
body: <p>I have an integer with a value <code>7</code> (<code>0b00000111</code>) And I would like to replace it with a function to <code>13</code> (<code>0b00001101</code>). What is the best algorithm to replace bits in an integer? </p>
  
  <p>For example:</p>
  
  <pre><code>set_bits(somevalue, 3, 1) # What makes the 3rd bit to 1 in somevalue?
  </code></pre>