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
>> a = int16(1.5 * 4)
a = 6
>> T = numerictype(1, 16, 2)
T = DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 2
>> dis = reinterpretcast(a, T)
dis = 1.5000
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 2
>> c = dis * dis
c = 2.2500
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 4
i wish the variable c
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.
EDIT : typing fimath
into command window cause error. Why does this error occur?
>> 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};