MATLAB Function Reference Previous page   Next Page
bitget

Get bit at specified position

Syntax

Description

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).

Examples

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:

See Also

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


Previous page  bitcmp bitmax Next page

© 1994-2005 The MathWorks, Inc.