int num = 1, z = 5; if (!(num <= 0)) Console.WriteLine( ++num + z++ + " " + ++z ); else Console.WriteLine( --num + z-- + " " + --z );
Console.WriteLine(13 / 2 + " " + 13 % 2);
if ((n&16) == 16)
Console.WriteLine("Fourth bit is ON");
if ((n&8) == 8)
Console.WriteLine("Fourth bit is ON");
if ((n ! 8) == 8)
Console.WriteLine("Fourth bit is ON");
if ((n ^ 8) == 8)
Console.WriteLine("Fourth bit is ON");
if ((n ~ 8) == 8)
Console. WriteLine("Fourth bit is ON");
if ((n&8) == 8)
Console.WriteLine("Fourth bit is ON");
byte myByte = 153; // In Binary = 10011001 byte n = 8; // In Binary = 00001000 (Here 1 is the 4th bit from right) Now perform logical AND operation (n & myByte) 10011001 00001000 --------- 00001000 Here result is other than 0, so evaluated to True. ---------If the result is true, then we can understand that 4th bit is ON of the given data myByte.
byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp);
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.