(x^0x1)! = What does 0 do?

Asked 2 years ago, Updated 2 years ago, 51 views

From the source code below, What does x^0x1 do? What rules do I not know?

if( 0 != ( x ^ 0x1 ) )
    encode( x, m );

c c++ bit-manipulation bitmask

2022-09-22 12:54

1 Answers

0x1 means hex 1.

If you look at the truth table of the XOR operation, alt text

You can see that xor 1 returns true if x is 0, and false if x is 1.

In other words, (x^0x1) checks whether x is 0 or not In other words, (x^0x1) = (x!=1).

You have to see the whole code It seems like a difficult code on purpose.


2022-09-22 12:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.