title: Saturating subtract/add for unsigned bytes
body: <p>Imagine I have two unsigned bytes <code>b</code> and <code>x</code>. I need to calculate <code>bsub</code> as <code>b - x</code> and <code>badd</code> as <code>b + x</code>. However, I don't want underflow/overflow occur during these operations. For example (pseudo-code):</p>
  
  <pre><code>b = 3; x = 5;
  bsub = b - x; // bsub must be 0, not 254
  </code></pre>
  
  <p>and</p>
  
  <pre><code>b = 250; x = 10;
  badd = b + x; // badd must be 255, not 4
  </code></pre>
  
  <p>The obvious way to do this includes branching:</p>
  
  <pre><code>bsub = b - min(b, x);
  badd = b + min(255 - b, x);
  </code></pre>
  
  <p>I just wonder if there are any better ways to do this, i.e. by some hacky bit manipulations?</p>