reinterpretcast
转换定点或整数数据类型而不更改基础数据
说明
示例
将 fi
对象转换为新数据类型
在此示例中,a
是有符号 fi
对象,其字长为 8 位、小数长度为 7 位。reinterpretcast
函数将 a
转换为无符号 fi
对象 c
,其字长为 8 位、小数长度为 0 位。a
和 c
的真实值不同,但其二进制表示是相同的。
a = fi([-1 pi/4],1,8,7)
a = -1.0000 0.7891 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 8 FractionLength: 7
T = numerictype(0,8,0); c = reinterpretcast(a,T)
c = 128 101 DataTypeMode: Fixed-point: binary point scaling Signedness: Unsigned WordLength: 8 FractionLength: 0
要验证基础数据未发生更改,请比较 a
和 c
的二进制表示。
binary_a = bin(a)
binary_a = '10000000 01100101'
binary_c = bin(c)
binary_c = '10000000 01100101'
输入参数
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
HDL 代码生成
使用 HDL Coder™ 为 FPGA 和 ASIC 设计生成 VHDL、Verilog 和 SystemVerilog 代码。
版本历史记录
在 R2008b 中推出
另请参阅
cast
| fi
| numerictype
| typecast
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)