byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp);
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.
int a = 10; int b = 20; bool c; c = !(a > b);
byte b1 = 0xAB; byte b2 = 0x99; byte temp; temp = (byte)~b2; Console.Write(temp + " "); temp = (byte)(b1 << b2); Console.Write (temp + " "); temp = (byte) (b2 >> 2); Console.WriteLine(temp);
int d; d = Convert.ToInt32( !(30 < 20) );
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.