Main Content

fimath for Rounding and Overflow Modes

Only rounding methods and overflow actions set prior to an operation withfi对象affect the outcome of those operations. Once you create afiobject in MATLAB®, changing its rounding or overflow settings does not affect its value. For example, consider thefi对象aandb:

p = fipref('NumberDisplay','RealWorldValue',...'NumericTypeDisplay','none','FimathDisplay','none'); T = numerictype('WordLength',8,“FractionLength”,7); F = fimath('RoundingMethod','Floor','OverflowAction','Wrap'); a = fi(1,T,F)
a = -1
b = fi(1,T)
b = 0.9922

Because you createawith afimathobjectFthat hasOverflowActionset toWrap, the value ofawraps to -1. Conversely, because you createbwith the defaultOverflowActionvalue ofSaturate, its value saturates to 0.9922.

Now, assign thefimathobjectFtob:

b.fimath = F
b = 0.9922

Because the assignment operation and corresponding overflow and saturation happened when you createdb, its value does not change when you assign it the newfimathobjectF.

Note

fi对象with no local fimath and created from a floating-point value always get constructed with aRoundingMethodofNearestand anOverflowActionofSaturate. To constructfi对象with differentRoundingMethodandOverflowActionproperties, specify the desiredRoundingMethodandOverflowActionproperties in theficonstructor.

For more information about thefimathobject and its properties, seefimath Object Properties