title: Working with Byte literals
body: <p>I'm using the following function to brighten up color values (it's a lambda in my code, but that shouldn't make a differende):</p>
  
  <pre><code>Function ReduceDistanceTo255(ByVal i As Byte) As Byte
      Return i + (255 - i) \ 2
  End Function
  </code></pre>
  
  <p>It won't compile, since the compiler interprets <code>255</code> and <code>2</code> as integers rather than bytes, making the result of type <code>Integer</code>. Unfortunately, <a href="https://stackoverflow.com/questions/252817">there is no Byte type character</a>, so I cannot just write <code>255B</code> or something like that.</p>
  
  <p>There are a few obvious workarounds to the problem:</p>
  
  <pre><code>Function ReduceDistanceTo255(ByVal i As Byte) As Byte
      Return i + (CByte(255) - i) \ CByte(2)
  End Function
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Function ReduceDistanceTo255(ByVal i As Byte) As Byte
      Return CByte(i + (255 - i) \ 2)
  End Function
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Function ReduceDistanceTo255(ByVal i As Byte) As Byte
      Dim FF As Byte = 255
      Dim two As Byte = 2
  
      Return i + (FF - i) \ two
  End Function
  </code></pre>
  
  <p>The first one is just plain ugly and hard to read, because <em>every</em> literal needs to be <code>CByte</code>d. The second one performs calculations in integers and then converts the result to Byte, which is OK, but not as elegant as a pure-Byte operation. The third workaround doesn't require <code>CByte</code>s, but it's drawbacks are obvious.</p>
  
  <p>Did I miss some (elegant) fourth option which allows me to do Byte-only-math without cluttering my formula with CBools?</p>