| MATLAB® | ![]() |
C = bitget(A, bit)
C = bitget(A, bit) returns the value of the bit at position bit in A. Operand 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).
The dec2bin function converts decimal numbers to binary. However, you can also use the bitget function to show the binary representation of a decimal number. Just test successive bits from most to least significant:
disp(dec2bin(13))
1101
C = bitget(uint8(13), 4:-1:1)
C =
1 1 0 1Prove that intmax sets all the bits to 1:
a = intmax('uint8');
if all(bitget(a, 1:8))
disp('All the bits have value 1.')
end
All the bits have value 1.bitand, bitcmp, bitmax, bitor, bitset, bitshift, bitxor
![]() | bitcmp | bitmax | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |