title: What's so special about 0x7f?
body: <p>I'm reading avro format specification and trying to understand its implementation. Here is the method for decoding <a href="https://avro.apache.org/docs/1.8.2/spec.html#schema_primitive" rel="noreferrer">long value</a>:</p>
  
  <pre><code>  @Override
    public long readLong() throws IOException {
      ensureBounds(10);
      int b = buf[pos++] &amp; 0xff;
      int n = b &amp; 0x7f;
      long l;
      if (b &gt; 0x7f) {
        b = buf[pos++] &amp; 0xff;
        n ^= (b &amp; 0x7f) &lt;&lt; 7;
        if (b &gt; 0x7f) {
          b = buf[pos++] &amp; 0xff;
          n ^= (b &amp; 0x7f) &lt;&lt; 14;
          if (b &gt; 0x7f) {
            b = buf[pos++] &amp; 0xff;
            n ^= (b &amp; 0x7f) &lt;&lt; 21;
            if (b &gt; 0x7f) {
              // only the low 28 bits can be set, so this won't carry
              // the sign bit to the long
              l = innerLongDecode((long)n);
            } else {
              l = n;
            }
          } else {
            l = n;
          }
        } else {
          l = n;
        }
      } else {
        l = n;
      }
      if (pos &gt; limit) {
        throw new EOFException();
      }
      return (l &gt;&gt;&gt; 1) ^ -(l &amp; 1); // back to two's-complement
    }
  </code></pre>
  
  <p>The question is why do we always check if <code>0x7f</code> less then the byte we just read?</p>