| MATLAB Function Reference | ![]() |
Syntax
Description
C = bitget(A, returns the value of the bit at position bit)
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).
Example 1
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:
Example 2
Prove 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.
See Also
bitand, bitcmp, bitmax, bitor, bitset, bitshift, bitxor
| bitcmp | bitmax | ![]() |
© 1994-2005 The MathWorks, Inc.