Use bitwise AND to determine if a number is odd. : Bitwise AND : Data Type C# Examples


C# Examples » Data Type » Bitwise AND »

 

Use bitwise AND to determine if a number is odd.









    
using  System;  
  
class  Example  {    
    public  static  void  Main()  {  
        ushort  num;    
  
        num  =  10;  
  
        if((num  &  1)  ==  1)  
            Console.WriteLine("This  won't  display.");  
  
        num  =  11;  
  
        if((num  &  1)  ==  1)  
            Console.WriteLine(num  +  "  is  odd.");  
  
    }  
}
    
   
  
   



Output

11 is odd.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Bitwise AND