I am using INT8, INT16, INT32 functions in MATLAB to cast tie numbers, for example, -0.5, -1.5, 0.5, 1.5 etc. The documentation of these functions mention that double and single values are rounded to the nearest integer value on conversion. So, when I cast -0.5 to INT8, INT16 or INT32, I receive -1. However, when I use the Data Type Conversion block in Simulink to cast -0.5 to INT8, INT16 or INT32, I receive 0. I have configured the Data Type Conversion block to round the values to the nearest integer value as well. I expect the behavior of MATLAB and Simulink to be identical when performing the same task.
MATLAB: Does INT8, INT16, INT32 casting in MATLAB round the values to a different integer from that of Simulink when both are configured to round to the nearest integer
castingintegerMATLABoffroundsimulink
Best Answer