Referring to page number 79 of " Java The complete Reference" 7th edition by Herbert Schildt. The author says : " If the integer’s value is larger than the range of a byte, it will be reduced modulo (the remainder of an integer division by the) byte’s range".
The range of byte in java is -128 to 127. So the maximum value that fits in a byte is 128. If an integer value is assigned to a byte as shown below :
int i = 257; byte b; b = (byte) i; Since 257 crosses the range 127, 257 % 127 = 3 should be stored in 'b'. But am getting the output as 1 instead of 3. Where have I gone wrong in understanding the concept?