| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
C = bitcmp(A)
C = bitcmp(A, n)
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.
With eight-bit arithmetic, the one's complement of 01100011 (decimal 99) is 10011100 (decimal 156):
C = bitcmp(uint8(99)) C = 156
The complement of hexadecimal A5 (decimal 165) is 5A:
x = hex2dec('A5')
x =
165
dec2hex(bitcmp(x, 8))
ans =
5ANext, find the complement of hexadecimal 000000A5:
dec2hex(bitcmp(x, 32)) ans = FFFFFF5A
bitand, bitget, bitmax, bitor, bitset, bitshift, bitxor
![]() | bitand | bitget | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |