private static void Main(string[] args) { Console.WriteLine("F0.Common"); Console.WriteLine(); int integer = GetInteger(args); Console.WriteLine($"{nameof(integer)} {integer} is {(Parity.IsEven(integer) ? "" : "not ")}even."); Console.WriteLine($"{nameof(integer)} {integer} is {(Parity.IsOdd(integer) ? "" : "not ")}odd."); Console.WriteLine(); const int min = -240; const int max = +240; Console.WriteLine($"{nameof(integer)} {integer} clamped to the inclusive range of {min} and {max}:"); Console.WriteLine(Comparable.Clamp(integer, min, max)); }
public void IfAnIntegerIsEvenlyDivisibleByTwo_ItIsEven_LeavingNoRemainder(int integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }
public void Even_16bitSignedInteger(short integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }
public void Odd_16bitUnsignedInteger(ushort integer) { Assert.True(Parity.IsOdd(integer)); Assert.False(Parity.IsEven(integer)); }
public void Odd_NativeSizedUnsignedInteger(nuint integer) { Assert.True(Parity.IsOdd(integer)); Assert.False(Parity.IsEven(integer)); }
public void Odd_8bitUnsignedInteger(byte integer) { Assert.True(Parity.IsOdd(integer)); Assert.False(Parity.IsEven(integer)); }
public void Even_NativeSizedSignedInteger(nint integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }
public void Odd_64bitUnsignedInteger(ulong integer) { Assert.True(Parity.IsOdd(integer)); Assert.False(Parity.IsEven(integer)); }
public void Even_64bitSignedInteger(long integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }
public void Even_8bitSignedInteger(sbyte integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }
public void Even_32bitUnsignedInteger(uint integer) { Assert.True(Parity.IsEven(integer)); Assert.False(Parity.IsOdd(integer)); }