public static BitwiseAnd ( object m, object n ) : object | ||
m | object | The first number. |
n | object | The second number. |
return | object |
public void BitwiseOr() { Assert.AreEqual(((Byte)2) | ((Byte)3), NumberUtils.BitwiseOr((Byte)2, (Byte)3)); #if NET_2_0 Assert.AreEqual(((SByte)2) | ((SByte)3), NumberUtils.BitwiseOr((SByte)2, (SByte)3)); #else try { NumberUtils.BitwiseOr((SByte)2, (SByte)3); Assert.Fail(); } catch (ArgumentException) { } #endif #if NET_2_0 Assert.AreEqual(((Int16)2) | ((Int16)3), NumberUtils.BitwiseOr((Int16)2, (Int16)3)); #else try { NumberUtils.BitwiseOr((Int16)2, (Int16)3); Assert.Fail(); } catch (ArgumentException) {} #endif Assert.AreEqual(((UInt16)2) | ((UInt16)3), NumberUtils.BitwiseOr((UInt16)2, (UInt16)3)); Assert.AreEqual(((Int32)2) | ((Int32)3), NumberUtils.BitwiseOr((Int32)2, (Int32)3)); Assert.AreEqual(((UInt32)2) | ((UInt32)3), NumberUtils.BitwiseOr((UInt32)2, (UInt32)3)); Assert.AreEqual(((Int64)2) | ((Int64)3), NumberUtils.BitwiseOr((Int64)2, (Int64)3)); Assert.AreEqual(((UInt64)2) | ((UInt64)3), NumberUtils.BitwiseOr((UInt64)2, (UInt64)3)); Assert.AreEqual(((UInt64)2) | ((Byte)3), NumberUtils.BitwiseOr((UInt64)2, (Byte)3)); Assert.AreEqual(false, NumberUtils.BitwiseOr(false, false)); Assert.AreEqual(true, NumberUtils.BitwiseOr(false, true)); try { NumberUtils.BitwiseAnd((double)2.0, 3); Assert.Fail(); } catch (ArgumentException) {} }
public void BitwiseAnd() { Assert.AreEqual(((Byte)2) & ((Byte)3), NumberUtils.BitwiseAnd((Byte)2, (Byte)3)); Assert.AreEqual(((SByte)2) & ((SByte)3), NumberUtils.BitwiseAnd((SByte)2, (SByte)3)); Assert.AreEqual(((Int16)2) & ((Int16)3), NumberUtils.BitwiseAnd((Int16)2, (Int16)3)); Assert.AreEqual(((UInt16)2) & ((UInt16)3), NumberUtils.BitwiseAnd((UInt16)2, (UInt16)3)); Assert.AreEqual(((Int32)2) & ((Int32)3), NumberUtils.BitwiseAnd((Int32)2, (Int32)3)); Assert.AreEqual(((UInt32)2) & ((UInt32)3), NumberUtils.BitwiseAnd((UInt32)2, (UInt32)3)); Assert.AreEqual(((Int64)2) & ((Int64)3), NumberUtils.BitwiseAnd((Int64)2, (Int64)3)); Assert.AreEqual(((UInt64)2) & ((UInt64)3), NumberUtils.BitwiseAnd((UInt64)2, (UInt64)3)); Assert.AreEqual(((UInt64)2) & ((Byte)3), NumberUtils.BitwiseAnd((UInt64)2, (Byte)3)); Assert.AreEqual(true, NumberUtils.BitwiseAnd(true, true)); Assert.AreEqual(false, NumberUtils.BitwiseAnd(false, true)); try { NumberUtils.BitwiseAnd((double)2.0, 3); Assert.Fail(); } catch (ArgumentException) {} }
public void BitwiseOr() { Assert.AreEqual((byte)2 | (byte)3, NumberUtils.BitwiseOr((byte)2, (byte)3)); Assert.AreEqual((sbyte)2 | (sbyte)3, NumberUtils.BitwiseOr((sbyte)2, (sbyte)3)); Assert.AreEqual((short)2 | (short)3, NumberUtils.BitwiseOr((short)2, (short)3)); Assert.AreEqual((ushort)2 | (ushort)3, NumberUtils.BitwiseOr((ushort)2, (ushort)3)); Assert.AreEqual((int)2 | (int)3, NumberUtils.BitwiseOr((int)2, (int)3)); Assert.AreEqual((uint)2 | (uint)3, NumberUtils.BitwiseOr((uint)2, (uint)3)); Assert.AreEqual((long)2 | (long)3, NumberUtils.BitwiseOr((long)2, (long)3)); Assert.AreEqual((ulong)2 | (ulong)3, NumberUtils.BitwiseOr((ulong)2, (ulong)3)); Assert.AreEqual((ulong)2 | (byte)3, NumberUtils.BitwiseOr((ulong)2, (byte)3)); Assert.AreEqual(false, NumberUtils.BitwiseOr(false, false)); Assert.AreEqual(true, NumberUtils.BitwiseOr(false, true)); try { NumberUtils.BitwiseAnd((double)2.0, 3); Assert.Fail(); } catch (ArgumentException) { } }