title: Matlab : how to perform fixed-point arithmetic without expanding underlying data type?
body: <p>Google is silent on this issue. I'm currently implementing a numerical calculator on only 16-bit signed fixed point in Matlab. But arithmetic operation on 16bit fixed point causes expanding data type to the following</p>
  
  <pre><code>&gt;&gt; a = int16(1.5 * 4)
  a = 6
  &gt;&gt; T = numerictype(1, 16, 2)
  
  T = DataTypeMode: Fixed-point: binary point scaling
              Signedness: Signed
              WordLength: 16
          FractionLength: 2
  &gt;&gt; dis = reinterpretcast(a, T)
  
  dis = 1.5000
  
            DataTypeMode: Fixed-point: binary point scaling
              Signedness: Signed
              WordLength: 16
          FractionLength: 2
  &gt;&gt; c = dis * dis
  
  c = 2.2500
  
            DataTypeMode: Fixed-point: binary point scaling
              Signedness: Signed
              WordLength: 32
          FractionLength: 4
  </code></pre>
  
  <p>i wish the variable <code>c</code> stays in WordLength 16, FractionLength 2. Is it possible that arithmetic operation on 16bit fixed point is done without expanding underlying data type? I'm going to take the risk of any overflow and underflow. Any help would be awesome.</p>
  
  <p><strong>EDIT</strong> : typing <code>fimath</code> into command window cause error. Why does this error occur?</p>
  
  <pre><code>&gt;&gt; F = fimath('OverflowAction','Wrap', 'RoundingMethod', 'Floor', ...
             'ProductWordLength', 16, 'ProductFractionLength', 2);
  No public field OverflowAction exists for class embedded.fimath.
  
  Error in fimath (line 72)
    this.(varargin{k}) = varargin{k+1};
  </code></pre>