//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
partial class HFlags {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit(int value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 31 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, 1 << bitNo );
}

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit(long value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 63 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, 1L << bitNo );
}

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit(short value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 15 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, unchecked( (short)(1 << bitNo) ) );
}

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit(byte value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 7 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, (byte)(1 << bitNo) );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant(false)]
public static bool CheckBit(uint value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 31 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, 1u << bitNo );
}

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant(false)]
public static bool CheckBit(ulong value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 63 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, 1ul << bitNo );
}

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant(false)]
public static bool CheckBit(ushort value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 15 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, (ushort)(1 << bitNo) );
}

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant(false)]
public static bool CheckBit(sbyte value,int bitNo)
{
   if ( !HOps.IsBetween( bitNo, 0, 7 ) )
      throw new ArgumentOutOfRangeException();
   return Check( value, unchecked( (sbyte)(1 << bitNo) ) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HFlags
//**************************************************************************************************

} // CommonHelpers (.WASM)
