+ 1
How 'y' gets -4 ?
6 Answers
+ 1
tilde is the sign for bitwise complement which effectively converts a number to binary flips the 1's & 0's and turns it back into an it
3 = 0000 0011
flipped = 1111 1100
which is binary for -4
+ 1
Not exactly, here's an example with 8 bit signed. the left most digit is the only negative digit and its equal to -2^3
so 1000 = -8
1100 = -8 + 2^2 = -4
1111 = -8 + 2^2 + 2^1+2^0 = -1
0
should it be like this?
3=011
-4=100
0
no, java int datatypes are 32 bit signed
it should technically be 0000 0000 0000 0011=3
0
so when flipped,shouldn't it be a large number(ignore the sign)
0
thank you very much for the clear explanationđđđ