rtGetNaN.cpp 1.4 KB

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