//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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 int ClearBit( ref int location, int bitNo ) =>
   location &= ~u.int32.Flag( bitNo );

/// <exception cref="ArgumentOutOfRangeException" />
public static long ClearBit( ref long location, int bitNo ) =>
   location &= ~u.int64.Flag( bitNo );

/// <exception cref="ArgumentOutOfRangeException" />
public static short ClearBit( ref short location, int bitNo ) =>
   location &= unchecked( (short)~u.int16.Flag( bitNo ) );

/// <exception cref="ArgumentOutOfRangeException" />
public static byte ClearBit( ref byte location, int bitNo ) =>
   location &= unchecked( (byte)~u.uint8.Flag( bitNo ) );

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

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static uint ClearBit( ref uint location, int bitNo ) =>
   location &= ~u.uint32.Flag( bitNo );

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static ulong ClearBit( ref ulong location, int bitNo ) =>
   location &= ~u.uint64.Flag( bitNo );

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static ushort ClearBit( ref ushort location, int bitNo ) =>
   location &= unchecked( (ushort)~u.uint16.Flag( bitNo ) );

/// <exception cref="ArgumentOutOfRangeException" />
[CLSCompliant( false )]
public static sbyte ClearBit( ref sbyte location, int bitNo ) =>
   location &= unchecked( (sbyte)~u.int8.Flag( bitNo ) );

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

} // user_rtx (.wasm)
