| MATLAB Function Reference | Search  Help Desk |
| bitget | Examples See Also |
C = bitget(A,bit)
C = bitget(A,bit)
returns the value of the bit at position bit in A. Operand A must be a nonnegative integer, and bit must be a number between 1 and the number of bits in the floating-point integer (flint) representation of A (52 for IEEE flints). To ensure the operand is an integer, use the ceil, fix, floor, and round functions.
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(13,4:-1:1)
C =
1 1 0 1
bitand Bit-wise AND
bitcmp Complement bits
bitmax Maximum floating-point integer
bitor Bit-wise OR
bitset Set bit
bitshift Bit-wise shift
bitxor Bit-wise XOR