bitcmp
按位补码
说明
示例
负整数的补码
A = int8(-11); cmp = bitcmp(A)
cmp = int8
10
当数字以二进制形式显示时,可以查看求补运算。
original = bitget(A,8:-1:1)
original = 1x8 int8 row vector
1 1 1 1 0 1 0 1
complement = bitget(bitcmp(A),8:-1:1)
complement = 1x8 int8 row vector
0 0 0 0 1 0 1 0
无符号的整数的补码
cmp = bitcmp(64,'uint8')
cmp = 191
maxint = intmax('uint8') - 64
maxint = uint8
191
无符号的整数的补码等于用其数据类型的最大整数减去其自身。
输入参数
A
— 输入值
有符号的整数数组 | 无符号的整数数组 | 双精度数组
输入值,指定为有符号的整数数组、无符号的整数数组或双精度数组。
如果
A
为双精度数组,并且未指定assumedtype
,则 MATLAB® 会将A
视为无符号的 64 位整数。如果已指定
assumedtype
,A
中的所有元素必须是assumedtype
类型范围内的整数值。
数据类型: double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
assumedtype
— 假定的 A
的数据类型
'uint64'
| 'uint32'
| 'uint16'
| 'uint8'
| 'int64'
| 'int32'
| 'int16'
| 'int8'
假定的 A
的数据类型,指定为 'uint64'
、'uint32'
、'uint16'
、'uint8'
、'int64'
、'int32'
、'int16'
或 'int8'
。
如果
A
是双精度数组,assumedtype
可以指定任何有效的整数类型,但默认为'uint64'
。如果
A
是整数类型数组,assumedtype
必须指定相同的整数类型。
数据类型: char
| string
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
GPU 代码生成
使用 GPU Coder™ 为 NVIDIA® GPU 生成 CUDA® 代码。
HDL 代码生成
使用 HDL Coder™ 为 FPGA 和 ASIC 设计生成 Verilog 代码和 VHDL 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅Run MATLAB Functions in Thread-Based Environment。
GPU 数组
通过使用 Parallel Computing Toolbox™ 在图形处理单元 (GPU) 上运行来加快代码执行。
用法说明和限制:
输入参数
A
必须是由无符号整数组成的gpuArray
。不支持 64 位整数。
不支持
assumedtype
参数。
有关详细信息,请参阅Run MATLAB Functions on a GPU (Parallel Computing Toolbox)。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)