bitcmp
Bit-wise complement
Description
Examples
A = int8(-11); cmp = bitcmp(A)
cmp = int8
10
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
cmp = bitcmp(64,'uint8')cmp = 191
maxint = intmax('uint8') - 64maxint = uint8
191
The complement of an unsigned integer is equal to itself subtracted from the maximum integer of its data type.
Input Arguments
Input value, specified as a signed integer array, unsigned integer array, or double array.
If
Ais a double array, andassumedtypeis not specified, then MATLAB® treatsAas an unsigned 64-bit integer.If
assumedtypeis specified, then all elements inAmust have integer values within the range ofassumedtype.
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'.
If
Ais a double array, thenassumedtypecan specify any valid integer type, but defaults to'uint64'.If
Ais an integer type array, thenassumedtypemust specify that same integer type.
Data Types: char | string
Output Arguments
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
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
The bitcmp function
supports GPU array input with these usage notes and limitations:
The input argument
Amust be agpuArrayof unsigned integers.64-bit integers are not supported.
The
assumedtypeargument is not supported.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)