title: How to calculate the range of primitive data types?
body: <p>According to docs.oracle.com:-</p>
  
  <p>byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.</p>
  
  <p>Byte - 8 bits<br>
   2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0</p>
  
  <p>128 64  32   16   8   4   2   1)</p>
  
  <p>Adding all these numbers we get a total of 255. Then how's the range which is -128 to 127 calculated. Is it hard-coded somewhere or there's some more technicality to this range?</p>
  
  <p>Any suggestions would be appreciated.</p>