Skip to Main Content Skip to Search
Product Documentation

Using fimath to Specify Rounding and Overflow Modes

Only rounding and overflow modes 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 mode 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('RoundMode','floor','OverflowMode','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 OverflowMode set to wrap, the value of a wraps to -1. Conversely, because you create b with the default OverflowMode 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.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS