BitHelper.SetFlag Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
SetFlag(UInt32, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt32, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt64, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt64, Int32, Boolean) |
Sets a bit to a specified value. |
SetFlag(UInt32, Int32, Boolean)
Sets a bit to a specified value.
public static uint SetFlag (uint value, int n, bool flag);
static member SetFlag : uint32 * int * bool -> uint32
Public Shared Function SetFlag (value As UInteger, n As Integer, flag As Boolean) As UInteger
Parameters
- n
- Int32
The position of the bit to set or clear (in [0, 31] range).
- flag
- Boolean
The value to assign to the target bit.
Returns
An UInt32 value equal to value
except for the n
-th bit.
Remarks
Just like HasFlag(UInt32, Int32), this method doesn't validate n
and does not contain branching instructions, so it's well suited for use in tight loops as well.
Applies to
SetFlag(UInt32, Int32, Boolean)
Sets a bit to a specified value.
public static void SetFlag (ref uint value, int n, bool flag);
static member SetFlag : uint32 * int * bool -> unit
Public Shared Sub SetFlag (ByRef value As UInteger, n As Integer, flag As Boolean)
Parameters
- n
- Int32
The position of the bit to set or clear (in [0, 31] range).
- flag
- Boolean
The value to assign to the target bit.
Remarks
Just like HasFlag(UInt32, Int32), this method doesn't validate n
and does not contain branching instructions, so it's well suited for use in tight loops as well.
Applies to
SetFlag(UInt64, Int32, Boolean)
Sets a bit to a specified value.
public static ulong SetFlag (ulong value, int n, bool flag);
static member SetFlag : uint64 * int * bool -> uint64
Public Shared Function SetFlag (value As ULong, n As Integer, flag As Boolean) As ULong
Parameters
- n
- Int32
The position of the bit to set or clear (in [0, 63] range).
- flag
- Boolean
The value to assign to the target bit.
Returns
An UInt64 value equal to value
except for the n
-th bit.
Remarks
Just like HasFlag(UInt64, Int32), this method doesn't validate n
and does not contain branching instructions, so it's well suited for use in tight loops as well.
Applies to
SetFlag(UInt64, Int32, Boolean)
Sets a bit to a specified value.
public static void SetFlag (ref ulong value, int n, bool flag);
static member SetFlag : uint64 * int * bool -> unit
Public Shared Sub SetFlag (ByRef value As ULong, n As Integer, flag As Boolean)
Parameters
- n
- Int32
The position of the bit to set or clear (in [0, 63] range).
- flag
- Boolean
The value to assign to the target bit.
Remarks
Just like HasFlag(UInt64, Int32), this method doesn't validate n
and does not contain branching instructions, so it's well suited for use in tight loops as well.