MATLAB: Does the generated code for the Data Type Conversion block perform temporary up-conversion to type double when I am using other data types in Real-Time Workshop Embedded Coder 5.0 (R2007b)

blockcastconversiondatadoubleEmbedded Codertypeuint16uint32

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

This enhancement has been incorporated in Release 2010a (R2010a). For previous product releases, read below for any possible workarounds:
The ability to avoid the temporary up-conversion to a double-precision data type when generating code for the Data Type Conversion block is not available with Real-Time Workshop Embedded Coder 5.0 (R2007b). This up-conversion occurs when the 'Round integer calculations toward' field is set to 'Floor', 'Nearest' or 'Ceiling' in the Data Type Conversion Block Parameters dialog box.
As a workaround, the following options can be set
1) In the parameters pane of the block, set the option 'Round integer calculations toward' field to 'Zero' or 'Simplest'.
2) In the configuration parameters, optimization pane, check the option, 'remove code from float to int conversions that wraps out-of-range values'.