function iA = stripscaling(A)
% MATLAB Code Generation library function for the @fi/stripscaling

% $INCLUDE(DOC) toolbox/eml/lib/fixedpoint/@embedded/@fi/stripscaling $
% Copyright 2002-2017 The MathWorks, Inc.
%#codegen
  
eml_allow_mx_inputs;

% Check for correct number of input arguments i.e. 1
eml_invariant(nargin==1, 'fixed:coder:incorrectNumberOfInputs');

if eml_ambiguous_types
    temp = eml_not_const(zeros(size(A)));
    if ~isreal(A)
        iA = complex(temp,temp);
    else
        iA = temp;
    end
    return;
end

if isfixed(A)
    % FI objects with Fixed datatype

    % Get the word length of & signedness of A
    Ta        = numerictype(A);
    Tout = numerictype('Scaling','BinaryPoint', 'Signed',Ta.Signed, 'WordLength', Ta.WordLength,'FractionLength',0);
    if ~isreal(A)
        Ar   = real(A); Ai = imag(A);
        iAr  = eml_fimathislocal(eml_reinterpret(Ar,Tout),eml_fimathislocal(A)); iAi = eml_fimathislocal(eml_reinterpret(Ai,Tout),eml_fimathislocal(A));
        iA = complex(iAr,iAi);
    else
        iA = eml_fimathislocal(eml_reinterpret(A,Tout),eml_fimathislocal(A));
    end

elseif isscaleddouble(A)
    % Scaled double FI
    Ta = numerictype(A);
    Tout = numerictype('Scaling','BinaryPoint', 'Signed',Ta.Signed, 'WordLength', Ta.WordLength,'FractionLength',0,...
        'DataType','scaleddouble');
    iA = eml_fimathislocal(fi(storedInteger(A),Tout,fimath(A)),eml_fimathislocal(A));
    
elseif isfloat(A)
    % True Double or True Single FI
    iA = A;
else
    % FI datatype not supported
    eml_fi_assert_dataTypeNotSupported('STRIPSCALING');
end
