0

what does this code do?

https://code.sololearn.com/c4ot0sKPOC00 it's the code for function that returns false if both of inputs are even or odd, otherwise it returns true. but , I didn't understand how does it works? can someone explain it to me?

23rd Mar 2022, 7:11 PM
shokin touch
3 ответов
0
! ! ( ( Ͼ & 1) ^ (1 & Ͽ ) ) The function uses bitwise & (and) to examine the lowest bit, which is a determinant whether a number is odd or even. (1 indicates odd; 0, even). It performs exclusive or ^ to determine whether they are different. Exclusive or is equivalent to the logical comparison operator !=. (True means not equal; False, equal) The ! ! (not not) operators are used to convert the binary result of ^ into a Boolean True/False. The first ! converts the result into Boolean type, but undesirably negates the value. The second ! negates the value again to restore the original meaning. You would get the same result with ( Ͼ & 1) != (1 & Ͽ ) But it wouldn't be as picturesque.
23rd Mar 2022, 9:01 PM
Brian
Brian - avatar
- 1
Its nothing more than comparison of two numbers
24th Mar 2022, 10:02 AM
Saad Khan
Saad Khan - avatar