I have a model with the Data Type Conversion block which converts an input signal of type single to type int16. The Data Type Conversion block has the 'Round integer calculations toward' field set to 'Floor' in the Data Type Conversion Block Parameters dialog box.
The code generated for the above model using Real-Time Workshop Embedded Coder 5.0 (R2007b) is:
real_T tmp; tmp = floor((real_T)mytest_U.In1); mytest_Y.Out1 = (int16_T)(tmp <= 32767.0 ? tmp >= -32768.0 ? tmp : -32768.0 :32767.0);
Here, the input is temporarily cast to a double-precision data type. However, I would like all the calculations to be done using the single-precision data type.
Best Answer