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