| MATLAB® | ![]() |
C = bitset(A, bit)
C = bitset(A, bit,
v)
C = bitset(A, bit) sets bit position 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, bit, v) sets the bit at position bit to the value v, which must be either 0 or 1.
Setting the fifth bit in the five-bit binary representation of the integer 9 (01001) yields 11001, or 25:
C = bitset(uint8(9), 5)
C =
25Repeatedly subtract powers of 2 from the largest uint32 value:
a = intmax('uint32')
for k = 1:32
a = bitset(a, 32-k+1, 0)
endbitand, bitcmp, bitget, bitmax, bitor, bitshift, bitxor
![]() | bitor | bitshift | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |