MATLAB Function Reference Previous page   Next Page
bitcmp

Return bitwise complement

Syntax

Description

C = bitcmp(A) returns the bitwise complement of A, where A is an unsigned integer or an array of unsigned integers.

C = bitcmp(A, n) returns the bitwise complement of A as an n-bit unsigned integer C. Input A may not have any bits set higher than n (that is, A may not have a value greater than 2^n-1). The value of n can be no greater than the number of bits in the unsigned integer class of A. For example, if the class of A is uint32, then n must be a positive integer less than 32.

Examples

Example 1

With eight-bit arithmetic, the one's complement of 01100011 (decimal 99) is 10011100 (decimal 156):

Example 2

The complement of hexadecimal A5 (decimal 165) is 5A:

Next, find the complement of hexadecimal 000000A5:

See Also

bitand, bitget, bitmax, bitor, bitset, bitshift, bitxor


Previous page  bitand bitget Next page

© 1994-2005 The MathWorks, Inc.