# MATLAB: GLOBALFIMATH has no effect for FI objects in Fixed-Point Designer (R2012b)

I may specify GLOBALFIMATH settings, but they do not have any effect on subsequently created FI objects. For example:
>> globalfimath('RoundingMethod', 'Floor');
>> fi(2.247, 0,8,1e-2,0)
ans =
2.2500
As I specify a 'Floor' rounding method, I would expect the answer to be 2.240, not 2.250

• If no rounding method, overflow action, or fimath is used in the argument list of the FI constructor, then it will always use nearest rounding (and saturate overflow), regardless of the GLOBALFIMATH setting.
This behavior first occured in the R2009b Fixed-Point Toolbox and is documented in its release notes. The documentation for which can be found here:
_"When you create a fi object in this way in R2009b, you may get different results. As of this release, the fi constructor creates the fi object using a RoundMode of nearest and an OverflowMode of saturate. Thus, the setting of the RoundMode and OverflowMode properties of the global fimath are not used to create fi objects from floating-point values."_
The FI object uses 'nearest' and 'saturate' for being consistent with the way Simulink constructs fixed-point parameters, and to insulate it from any global settings.
The recommended way to construct a FI object that obeys the GLOBALFIMATH settings is to use the CAST function, which is available since R2013a: http://www.mathworks.com/help/releases/R2013a/matlab/ref/cast.html
The CAST function will always obey the "fimath" in force for the 'like' variable (either attached to the 'like' variable or 'globalfimath'). For example:
>> resetglobalfimath; % To ensure a clean state
>> globalfimath('RoundingMethod', 'Floor');
>> h = cast(2.247, 'like', fi([], 0,8,1e-2,0)) % Floor rounding
h =
2.2400
>> globalfimath('RoundingMethod', 'Ceiling');
>> h = cast(2.247, 'like', fi([], 0,8,1e-2,0)) % Ceiling rounding
h =
2.2500