Documentation Center

  • Trial Software
  • Product Updates

fimath for Rounding and Overflow Modes

Only rounding methods and overflow actions set prior to an operation with fi objects affect the outcome of those operations. Once you create a fi object in MATLAB®, changing its rounding or overflow settings does not affect its value. For example, consider the fi objects a and b:

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 create a with a fimath object F that has OverflowAction set to Wrap, the value of a wraps to -1. Conversely, because you create b with the default OverflowAction value of Saturate, its value saturates to 0.9922.

Now, assign the fimath object F to b:

b.fimath = F
b =
 
    0.9922

Because the assignment operation and corresponding overflow and saturation happened when you created b, its value does not change when you assign it the new fimath object F.

    Note:   fi objects with no local fimath and created from a floating-point value always get constructed with a RoundingMethod of Nearest and an OverflowAction of Saturate. To construct fi objects with different RoundingMethod and OverflowAction properties, specify the desired RoundingMethod and OverflowAction properties in the fi constructor.

For more information about the fimath object and its properties, see fimath Object Properties

Was this topic helpful?