/// <summary>Modifies bits in a 16bit value</summary> /// <param name="Value">value to modify</param> /// <param name="ClearBits">Bit mask of bits in value to clear</param> /// <param name="SetBits">Bit mask of bits in value to set</param> public static void ModifyBits(ref ushort Value, Bits16 ClearBits, Bits16 SetBits) { Value = ( ushort )( ( Value & ( ushort )( ~ClearBits ) ) | ( ushort )SetBits ); }
/// <summary>Tests if any of the bits specified are set in a value</summary> /// <param name="Value">Value to test bits in</param> /// <param name="TestBits">Bit mask of bits to test in Value</param> /// <returns>true if any of the bits specified in TestBits is set in Value</returns> public static bool AnyBitsSet(ushort Value, Bits16 TestBits) { return 0 != ((ushort)TestBits & Value); }
/// <summary>Tests if any of the bits specified are set in a value</summary> /// <param name="Value">Value to test bits in</param> /// <param name="TestBits">Bit mask of bits to test in Value</param> /// <returns>true if any of the bits specified in TestBits is set in Value</returns> public static bool AnyBitsSet(ushort Value, Bits16 TestBits) { return(0 != ((ushort)TestBits & Value)); }
/// <summary>Tests if all the specified bits are set in a Value</summary> /// <param name="Value">Value to test</param> /// <param name="TestBits">Bit mask of bits to test in Value</param> /// <returns>true, if ALL the bits specified in TestBits are set</returns> public static bool AllBitsSet(ushort Value, Bits16 TestBits) { return (ushort)TestBits == ((ushort)TestBits & Value); }
/// <summary>Modifies bits in a 16bit value</summary> /// <param name="Value">value to modify</param> /// <param name="ClearBits">Bit mask of bits in value to clear</param> /// <param name="SetBits">Bit mask of bits in value to set</param> public static void ModifyBits(ref ushort Value, Bits16 ClearBits, Bits16 SetBits) { Value = ( ushort )((Value & ( ushort )(~ClearBits)) | ( ushort )SetBits); }