title: Compiler warnings conversion
body: <p>We are compiling using gcc with <code>-Wconversion</code> enabled. I get following warnings when I left shift result returned by <code>isBitSet</code> function below. </p>
  
  <blockquote>
    <p>warning: conversion to 'u_int16_t {aka short unsigned int}' from 'int'
    may alter its value [-Wconversion]</p>
  </blockquote>
  
  <pre><code>#include &lt;stdint.h&gt;
  
  using namespace std;
  
  void convertToPos(uint16 in) {
  
      auto isBitSet = [&amp;in](uint8_t position) -&gt; bool{
          return (in &amp; (1 &lt;&lt; position));
      };
  
      uint16_t signal = 0;
      signal |= isBitSet(1) &lt;&lt; 9;  // Calibrated
      signal |= isBitSet(2) &lt;&lt; 10; // Corresponds to digital map
      signal |= isBitSet(5) &lt;&lt; 13; // DR
      signal |= isBitSet(8) &lt;&lt; 15; // 3D Fix
  
  }
  
  int main(int argc)
  {
      convertToPos(4);
      return 0;
  }
  </code></pre>
  
  <p>I tried changing lambda to below, but still I get the same error. How can I fix it?</p>
  
  <pre><code>auto isBitSet = [&amp;in](uint8_t position) -&gt; uint16_t {
      return (in &amp; (1 &lt;&lt; position)) ? 1u:0u;
  };
  </code></pre>