MATLAB Function Reference |

**Syntax**

**Description**

`C = bitset(A, `

sets bit position

)
*bit*

in *bit*`A`

to 1 (on). `A`

must be an unsigned integer or an array of unsigned integers, and

must be a number between 1 and the number of bits in the unsigned integer class of *bit*`A`

(e.g., 32 for the `uint32`

class).

`C = bitset(A,`

sets the bit at position

, v)
* bit*

to the value *bit*`v`

, which must be either 0 or 1.

**Example 1**

Setting the fifth bit in the five-bit binary representation of the integer 9 (01001) yields 11001, or 25:

**Example 2**

Repeatedly subtract powers of 2 from the largest `uint32`

value:

**See Also **

`bitand`

, `bitcmp`

, `bitget`

, `bitmax`

, `bitor`

, `bitshift`

, `bitxor`

bitor | bitshift |

© 1994-2005 The MathWorks, Inc.