MATLAB Function Reference    
bitget

Get bit

Syntax

Description

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.

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:

See Also

bitand, bitcmp, bitmax, bitor, bitset, bitshift, bitxor


  bitcmp bitmax