1 /*
2 * File: rtGetInf.c
3 *
4 * MATLAB Coder version : 3.1
5 * C/C++ source code generated on : 22-Apr-2021 15:58:03
6 */
7
8 /*
9 * Abstract:
10 * MATLAB for code generation function to initialize non-finite, Inf and MinusInf
11 */
12 #include "rtGetInf.h"
13 #define NumBitsPerChar 8U
14
15 /* Function: rtGetInf ==================================================
16 * Abstract:
17 * Initialize rtInf needed by the generated code.
18 * Inf is initialized as non-signaling. Assumes IEEE.
19 */
20 real_T rtGetInf(void)
21 {
22 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
23 real_T inf = 0.0;
24 if (bitsPerReal == 32U) {
25 inf = rtGetInfF();
26 } else {
27 uint16_T one = 1U;
28 enum {
29 LittleEndian,
30 BigEndian
31 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
32 switch (machByteOrder) {
33 case LittleEndian:
34 {
35 union {
36 LittleEndianIEEEDouble bitVal;
37 real_T fltVal;
38 } tmpVal;
39
40 tmpVal.bitVal.words.wordH = 0x7FF00000U;
41 tmpVal.bitVal.words.wordL = 0x00000000U;
42 inf = tmpVal.fltVal;
43 break;
44 }
45
46 case BigEndian:
47 {
48 union {
49 BigEndianIEEEDouble bitVal;
50 real_T fltVal;
51 } tmpVal;
52
53 tmpVal.bitVal.words.wordH = 0x7FF00000U;
54 tmpVal.bitVal.words.wordL = 0x00000000U;
55 inf = tmpVal.fltVal;
56 break;
57 }
58 }
59 }
60
61 return inf;
62 }
63
64 /* Function: rtGetInfF ==================================================
65 * Abstract:
66 * Initialize rtInfF needed by the generated code.
67 * Inf is initialized as non-signaling. Assumes IEEE.
68 */
69 real32_T rtGetInfF(void)
70 {
71 IEEESingle infF;
72 infF.wordL.wordLuint = 0x7F800000U;
73 return infF.wordL.wordLreal;
74 }
75
76 /* Function: rtGetMinusInf ==================================================
77 * Abstract:
78 * Initialize rtMinusInf needed by the generated code.
79 * Inf is initialized as non-signaling. Assumes IEEE.
80 */
81 real_T rtGetMinusInf(void)
82 {
83 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
84 real_T minf = 0.0;
85 if (bitsPerReal == 32U) {
86 minf = rtGetMinusInfF();
87 } else {
88 uint16_T one = 1U;
89 enum {
90 LittleEndian,
91 BigEndian
92 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
93 switch (machByteOrder) {
94 case LittleEndian:
95 {
96 union {
97 LittleEndianIEEEDouble bitVal;
98 real_T fltVal;
99 } tmpVal;
100
101 tmpVal.bitVal.words.wordH = 0xFFF00000U;
102 tmpVal.bitVal.words.wordL = 0x00000000U;
103 minf = tmpVal.fltVal;
104 break;
105 }
106
107 case BigEndian:
108 {
109 union {
110 BigEndianIEEEDouble bitVal;
111 real_T fltVal;
112 } tmpVal;
113
114 tmpVal.bitVal.words.wordH = 0xFFF00000U;
115 tmpVal.bitVal.words.wordL = 0x00000000U;
116 minf = tmpVal.fltVal;
117 break;
118 }
119 }
120 }
121
122 return minf;
123 }
124
125 /* Function: rtGetMinusInfF ==================================================
126 * Abstract:
127 * Initialize rtMinusInfF needed by the generated code.
128 * Inf is initialized as non-signaling. Assumes IEEE.
129 */
130 real32_T rtGetMinusInfF(void)
131 {
132 IEEESingle minfF;
133 minfF.wordL.wordLuint = 0xFF800000U;
134 return minfF.wordL.wordLreal;
135 }
136
137 /*
138 * File trailer for rtGetInf.c
139 *
140 * [EOF]
141 */
142
|