为什么MatLab不使用globalfimath属性

4视图(30天)
我设置globalfimath属性代码:
resetglobalfimath;
调频= fimath (
“ProductMode”,“SpecifyPrecision”,
“MaxProductWordLength”字,
“ProductWordLength”字,
“ProductFractionLength”FractionalLength,
“SumMode”,“SpecifyPrecision”,
“MaxSumWordLength”字,
“SumWordLength”字,
“SumFractionLength”FractionalLength,
“OverflowAction”,“包装”,
“RoundingMethod”,“地板”);
globalfimath (Fm)
我得到正确的属性返回……例如:
> > fimath
ans =
RoundingMethod:地板
OverflowAction:包装
ProductMode: SpecifyPrecision
ProductWordLength: 64
ProductFractionLength: 53
SumMode: SpecifyPrecision
SumWordLength: 64
SumFractionLength: 53
CastBeforeSum:真
如果我现在尝试使用fi()构造函数似乎他总是创建一个本地fi-object。例如我得到这个:
> > = fi(π)
一个=
3.1416
DataTypeMode:定点:二进制扩展
Signedness:签署
字:16
FractionLength: 13
我能做些什么来得到相同的单词,每fi-object franctionlength吗?

答案(1)

杰西卡·克莱顿
杰西卡·克莱顿 2020年12月2日
我知道你想使用 globalfimath 设置单词长度和分数都有相同的值 fi 对象。 fimath 控件上执行算术运算的规则 fi 对象,但是它不能控制这个词长度或部分的长度 fi 对象。你可以检查 fimath 属性定义应用于施工 fi 对象的使用 A.fimath 和确认指定的输出是一样的 globalfimath
字= 64;
FractionalLength = 53个;
resetglobalfimath;
调频= fimath (
“ProductMode”,“SpecifyPrecision”,
“MaxProductWordLength”字,
“ProductWordLength”字,
“ProductFractionLength”FractionalLength,
“SumMode”,“SpecifyPrecision”,
“MaxSumWordLength”字,
“SumWordLength”字,
“SumFractionLength”FractionalLength,
“OverflowAction”,“包装”,
“RoundingMethod”,“地板”);
globalfimath (Fm);
一个= fi (pi);
A.fimath
ans =
RoundingMethod:地板
OverflowAction:包装
ProductMode: SpecifyPrecision
ProductWordLength: 64
ProductFractionLength: 53
SumMode: SpecifyPrecision
SumWordLength: 64
SumFractionLength: 53
CastBeforeSum:真
ans =
RoundingMethod:地板
OverflowAction:包装
ProductMode: SpecifyPrecision
ProductWordLength: 64
ProductFractionLength: 53
SumMode: SpecifyPrecision
SumWordLength: 64
SumFractionLength: 53
CastBeforeSum:真
一种方法将同一个词长度和比例分配给每一个 fi 对象是使用记录的“铸像”的功能 在这里 。例如,
=π;
p = fi([], 64, 53岁);
b =投(a,“喜欢”,p)
b.fimath
b =
3.1416
DataTypeMode:定点:二进制扩展
Signedness:签署
字:64
FractionLength: 53
ans =
RoundingMethod:地板
OverflowAction:包装
ProductMode: SpecifyPrecision
ProductWordLength: 64
ProductFractionLength: 53
SumMode: SpecifyPrecision
SumWordLength: 64
SumFractionLength: 53
CastBeforeSum:真