Equality and complement operator | Sololearn: Learn to code for FREE!
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

26th Jul 2020, 3:05 AM
Ahmed Mahmoud
Ahmed Mahmoud - avatar
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
26th Jul 2020, 3:49 AM
Anis
Anis - avatar
+ 2
i got it thanks šŸŒŗ
26th Jul 2020, 4:07 AM
Ahmed Mahmoud
Ahmed Mahmoud - avatar