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

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class bitwise {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit( int value, int bitNo ) =>
   Check( value, 1 << u.arg_check.InRange( bitNo, 0, 31, nameof(bitNo) ) );

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit( long value, int bitNo ) =>
   Check( value, 1L << u.arg_check.InRange( bitNo, 0, 63, nameof(bitNo) ) );

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit( short value, int bitNo ) =>
   Check( value, unchecked( (short)(1 << u.arg_check.InRange( bitNo, 0, 15, nameof(bitNo) ))));

/// <exception cref="ArgumentOutOfRangeException" />
public static bool CheckBit( byte value, int bitNo ) =>
   Check( value, (byte)(1 << u.arg_check.InRange( bitNo, 0, 7, nameof(bitNo) )));

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

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static bool CheckBit( uint value, int bitNo ) =>
   Check( value, 1u << u.arg_check.InRange( bitNo, 0, 31, nameof(bitNo) ) );

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static bool CheckBit( ulong value, int bitNo ) =>
   Check( value, 1ul << u.arg_check.InRange( bitNo, 0, 63, nameof(bitNo) ) );

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static bool CheckBit( ushort value, int bitNo ) =>
   Check( value, (ushort)(1 << u.arg_check.InRange( bitNo, 0, 15, nameof(bitNo) )));

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static bool CheckBit( sbyte value, int bitNo ) =>
   Check( value, unchecked( (sbyte)(1 << u.arg_check.InRange( bitNo, 0, 7, nameof(bitNo) ))));

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // bitwise

} // user_rtx (.wasm)
