7th Aug 2018, 4:17 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
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
7th Aug 2018, 5:41 AM
JME
+ 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
7th Aug 2018, 7:13 AM
JME
0
should it be like this? 3=011 -4=100
7th Aug 2018, 5:54 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
0
no, java int datatypes are 32 bit signed it should technically be 0000 0000 0000 0011=3
7th Aug 2018, 5:58 AM
JME
0
so when flipped,shouldn't it be a large number(ignore the sign)
7th Aug 2018, 6:38 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
0
thank you very much for the clear explanation👊👊👊
7th Aug 2018, 7:19 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar