MATLAB Function Reference |
Syntax
Description
C = bitset(A,
sets bit position bit
)
bit
in A
to 1 (on). A
must be an unsigned integer or an array of unsigned integers, and bit
must be a number between 1 and the number of bits in the unsigned integer class of A
(e.g., 32 for the uint32
class).
C = bitset(A,
sets the bit at position bit
, v)
bit
to the value 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.