Why 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)?
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!