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!