+ 1
When we assign byte value as 130 in java then it gives -126 why this result is come? I don't understand..
3 Réponses
+ 6
Because of the limits of the type byte: between -128 and 127, when incrementing it above the upper limit it starts again from the lower limit, so we need to increase it 3 times above the upper limit (130 -127 = 3). First step => -128, second => -127 and third => -126 is the final result.
+ 5
Just adding to WhiteCat's explanation, this is called an overflow.
https://en.m.wikipedia.org/wiki/Integer_overflow