bitcmp - Bit-wise complement - MATLAB (original) (raw)

Syntax

Description

[cmp](#bth5q%5Fz-1-cmp) = bitcmp([A](#bth5q%5Fz-1-A)) returns the bit-wise complement of A.

example

[cmp](#bth5q%5Fz-1-cmp) = bitcmp([A](#bth5q%5Fz-1-A),[assumedtype](#bth5q%5Fz-1-assumedtype)) assumes that A is of assumedtype.

example

Examples

collapse all

A = int8(-11); cmp = bitcmp(A)

You can see the complement operation when the numbers are shown in binary.

original = bitget(A,8:-1:1)

original = 1×8 int8 row vector

1 1 1 1 0 1 0 1

complement = bitget(bitcmp(A),8:-1:1)

complement = 1×8 int8 row vector

0 0 0 0 1 0 1 0

maxint = intmax('uint8') - 64

The complement of an unsigned integer is equal to itself subtracted from the maximum integer of its data type.

Input Arguments

collapse all

Input value, specified as a signed integer array, unsigned integer array, or double array.

Data Types: double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Assumed data type of A, specified as 'uint64', 'uint32', 'uint16', 'uint8', 'int64', 'int32', 'int16', or 'int8'.

Data Types: char | string

Output Arguments

collapse all

Bit-wise complement, returned as a signed integer array, unsigned integer array, or double array. cmp is the same size and type as A.

Extended Capabilities

expand all

The bitcmp function supports GPU array input with these usage notes and limitations:

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a