I am trying to convert an int to byte.
int i = 128;
byte b = (byte) i;
I know the range of byte if -128 to 127 and the rule of storing an integer to a byte is :
byte_value = int_vale % byte_Range; (I found that in Complete reference Java)
When I apply this to int 128 it should be like this:
byte_value = 128%256 = 128;
But, it actually is : -128
I am not able to understand the actual logic behind this. Please help!!