+ 1

int i = 2, j = i; if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1))) Console.WriteLine(1); else Console.WriteLine(0);

what is the output please explain

2nd Oct 2017, 9:24 AM
ASHOK KUMAR
ASHOK KUMAR - avatar
1 Resposta
+ 12
int i = 2; // 0000 0010 int j = i; // 0000 0010 if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1))) Console.WriteLine(1); else Console.WriteLine(0); for (i | ( j & 5)) we have 0000 0010 = 2 & 0000 0101 = 5 ------------------ 0000 0000 = 0 | 0000 0010 = 2 --------------------- 0000 0010 = 2 (j - 25 * 1) = -23 = 1110 1001 (23 = 0001 0111) 0000 0010 = 2 & 1110 1001 = -23 --------------------- 0000 0000 = 0 Here, our evaluation yields 0 and if (false) then program flow picks else and output will be 0;
2nd Oct 2017, 9:49 AM
Babak
Babak - avatar