title: What is the optimal way to ensure a max absolute value, but preserve the sign?
body: <p>Say we have code like;</p>
  
  <pre><code>if (x &gt; 6) {
      x = 6;
  }
  if (x &lt; -6) {
      x = -6;
  }
  </code></pre>
  
  <p>Can we reduce this to one check and one update?</p>
  
  <p>We could do this, but we lose the sign.</p>
  
  <pre><code>if (abs(x) &gt; 6) {
      x = 6;
  }
  </code></pre>
  
  <p>(i'm not assuming any particular language)</p>