MATLAB 帮助中心
本页翻译不是最新的。点击此处可查看最新英文版本。
转换定点或整数数据类型而不更改基础数据
c = reinterpretcast(a,T)
c = reinterpretcast(a,T) 将输入 a 转换为 numerictype 对象 T 指定的数据类型而不更改基础数据。结果在 fi 对象 c 中返回。
c
a
T
numerictype
fi
reinterpretcast 函数与 MATLAB® typecast 和 cast 函数的不同之处在于,它只对 fi 对象和内置整数执行运算,它不允许输入的字长发生变化。
reinterpretcast
typecast
cast
示例
全部折叠
在此示例中,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'
输入定点或整数数组,指定为标量、向量、矩阵或多维数组。
输入 a 和 T 的字长必须相同。
数据类型: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi 复数支持: 是
int8
int16
int32
int64
uint8
uint16
uint32
uint64
新数据类型,指定为完全指定一种定点数据类型的 numerictype 对象。
全部展开
在 R2008b 中推出
cast | fi | numerictype | typecast
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处