MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 请教matlab定点计算溢出的问题 (https://www.labfans.com/bbs/showthread.php?t=21380)

az1981cn 2019-09-09 19:25

请教matlab定点计算溢出的问题
 
[CODE]T.F = fimath('SumMode','SpecifyPrecision', 'SumWordLength', 10, 'SumFractionLength', 4);
a=fi(-32,1,10,4,T.F)
b=fi(-1.5,1,10,4,T.F)
c=fi(-25.9375,1,10,4,T.F)
d=fi(9,1,10,4,T.F)

K>> a+b+c+d

ans =

-23

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 10
FractionLength: 4

RoundingMethod: Nearest
OverflowAction: Saturate
ProductMode: FullPrecision
SumMode: SpecifyPrecision
SumWordLength: 10
SumFractionLength: 4
CastBeforeSum: true[/CODE]

为什么输出结果是-23,而不是-32呢?


所有时间均为北京时间。现在的时间是 12:24

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.