Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 5
Equality and complement operator
Why x = 0 ?? Here šš Or how is the complement of 0 gives -1 ??? https://code.sololearn.com/clyjS6Sy2UNC/?ref=app
2 Respostas
+ 7
Well in C for any integerĀ n, bitwise complement ofĀ nĀ will beĀ -(n+1). To understand this, you should have the knowledge of 2's complement.
It works like this
First it converts the given decimal number to its correspondingĀ binaryĀ value.That is in case of 0 it converts it to 0000 0000 (to 8 bit binary number).
Then it converts it to the ones complement , 1111 1111
that is the 2's complement representation of -1
So -1 == ~0 outputs 1(true)
x = 1 - 1
+ 2
i got it thanks šŗ