+ 3
Can u explain me logic behind how the output came?
I would like to know as if i change the value from 130 to 123,or any number than what internally is going on and the output came by the compiler. https://code.sololearn.com/c0bsX3E9wf0f/?ref=app
5 odpowiedzi
+ 4
First understand how the range thing works before you understand the code.
https://stackoverflow.com/questions/3621067/why-is-the-range-of-bytes-128-to-127-in-java/42623517
+ 4
byte has a range from -128 to 127.
So anything beyond 127 will again start from -128. If you give 130 then the result will be 127+3 = -126.
+ 3
Got it avinesh thank u
+ 2
Yes sir internally what thing is happening is that their we have to find the 2's complements of the bits leaving most significant one ☝. Its a better way to remember it in a way like -x-1😅
+ 2
b++
01111101 125
01111110 126
01111111 127
10000000 -128
10000001 -127
10000010 -126