1 | /* |
2 | * File: rtGetNaN.c |
3 | * |
4 | * Code generated for Simulink model 'untitled'. |
5 | * |
6 | * Model version : 1.0 |
7 | * Simulink Coder version : 8.12 (R2017a) 16-Feb-2017 |
8 | * C/C++ source code generated on : Thu Mar 14 11:23:20 2019 |
9 | * |
10 | * Target selection: ert.tlc |
11 | * Embedded hardware selection: Atmel->AVR |
12 | * Code generation objectives: Unspecified |
13 | * Validation result: Not run |
14 | */ |
15 | |
16 | /* |
17 | * Abstract: |
18 | * Function to initialize non-finite, NaN |
19 | */ |
20 | #include "rtGetNaN.h" |
21 | #define NumBitsPerChar 8U |
22 | |
23 | /* |
24 | * Initialize rtNaN needed by the generated code. |
25 | * NaN is initialized as non-signaling. Assumes IEEE. |
26 | */ |
27 | real_T rtGetNaN(void) |
28 | { |
29 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); |
30 | real_T nan = 0.0; |
31 | if (bitsPerReal == 32U) { |
32 | nan = rtGetNaNF(); |
33 | } else { |
34 | union { |
35 | LittleEndianIEEEDouble bitVal; |
36 | real_T fltVal; |
37 | } tmpVal; |
38 | |
39 | tmpVal.bitVal.words.wordH = 0xFFF80000U; |
40 | tmpVal.bitVal.words.wordL = 0x00000000U; |
41 | nan = tmpVal.fltVal; |
42 | } |
43 | |
44 | return nan; |
45 | } |
46 | |
47 | /* |
48 | * Initialize rtNaNF needed by the generated code. |
49 | * NaN is initialized as non-signaling. Assumes IEEE. |
50 | */ |
51 | real32_T rtGetNaNF(void) |
52 | { |
53 | IEEESingle nanF = { { 0 } }; |
54 | |
55 | nanF.wordL.wordLuint = 0xFFC00000U; |
56 | return nanF.wordL.wordLreal; |
57 | } |
58 | |
59 | /* |
60 | * File trailer for generated code. |
61 | * |
62 | * [EOF] |
63 | */ |
64 |