Use bitwise AND to determine if a number is odd : Operator bitwise : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Operator bitwise »

 

Use bitwise AND to determine if a number is odd









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
//  Use bitwise AND to determine if a number is odd. 
using System; 
 
public class IsOdd {  
  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."); 
 
  } 
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Operator bitwise