MATLAB Function Reference |

**Syntax**

**Description**

`C = bitset(A,`

sets bit position

)
*bit*

in *bit*`A`

to 1 (on). `A`

must be a nonnegative integer and

must be a number between 1 and the number of bits in the floating-point integer (flint) representation of *bit*`A`

(52 for IEEE flints). To ensure the operand is an integer, use the `ceil`

, `fix`

, `floor`

, and `round`

functions.

`C = bitset(A,`

sets the bit at position

,v)
*bit*

to the value *bit*`v`

, which must be either 0 or 1.

**Examples**

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

**See Also **

`bitand`

, `bitcmp`

, `bitget`

, `bitmax`

, `bitor`

, `bitshift`

, `bitxor`

bitor | bitshift |