-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrt_nonfinite.c
96 lines (86 loc) · 2.51 KB
/
rt_nonfinite.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Academic License - for use in teaching, academic research, and meeting
* course requirements at degree granting institutions only. Not for
* government, commercial, or other organizational use.
*
* File: rt_nonfinite.c
*
* Code generated for Simulink model 'tv_code'.
*
* Model version : 1.30
* Simulink Coder version : 9.8 (R2022b) 13-May-2022
* C/C++ source code generated on : Wed Feb 26 15:34:24 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "rtGetNaN.h"
#include "rtGetInf.h"
#include <stddef.h>
#include "rtwtypes.h"
#include "rt_nonfinite.h"
#define NumBitsPerChar 8U
real_T rtInf;
real_T rtMinusInf;
real_T rtNaN;
real32_T rtInfF;
real32_T rtMinusInfF;
real32_T rtNaNF;
/*
* Initialize the rtInf, rtMinusInf, and rtNaN needed by the
* generated code. NaN is initialized as non-signaling. Assumes IEEE.
*/
void rt_InitInfAndNaN(size_t realSize)
{
(void) (realSize);
rtNaN = rtGetNaN();
rtNaNF = rtGetNaNF();
rtInf = rtGetInf();
rtInfF = rtGetInfF();
rtMinusInf = rtGetMinusInf();
rtMinusInfF = rtGetMinusInfF();
}
/* Test if value is infinite */
boolean_T rtIsInf(real_T value)
{
return (boolean_T)((value==rtInf || value==rtMinusInf) ? 1U : 0U);
}
/* Test if single-precision value is infinite */
boolean_T rtIsInfF(real32_T value)
{
return (boolean_T)(((value)==rtInfF || (value)==rtMinusInfF) ? 1U : 0U);
}
/* Test if value is not a number */
boolean_T rtIsNaN(real_T value)
{
boolean_T result = (boolean_T) 0;
size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
if (bitsPerReal == 32U) {
result = rtIsNaNF((real32_T)value);
} else {
union {
LittleEndianIEEEDouble bitVal;
real_T fltVal;
} tmpVal;
tmpVal.fltVal = value;
result = (boolean_T)((tmpVal.bitVal.words.wordH & 0x7FF00000) == 0x7FF00000 &&
( (tmpVal.bitVal.words.wordH & 0x000FFFFF) != 0 ||
(tmpVal.bitVal.words.wordL != 0) ));
}
return result;
}
/* Test if single-precision value is not a number */
boolean_T rtIsNaNF(real32_T value)
{
IEEESingle tmp;
tmp.wordL.wordLreal = value;
return (boolean_T)( (tmp.wordL.wordLuint & 0x7F800000) == 0x7F800000 &&
(tmp.wordL.wordLuint & 0x007FFFFF) != 0 );
}
/*
* File trailer for generated code.
*
* [EOF]
*/