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:
Related in same category :
-
-
|