rtGetInf.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "rtwtypes.h"
  2. #include "rtGetInf.h"
  3. #include <stddef.h>
  4. #include "rt_nonfinite.h"
  5. #define NumBitsPerChar 8U
  6. real_T rtGetInf(void)
  7. {
  8. size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
  9. real_T inf = 0.0;
  10. if (bitsPerReal == 32U) {
  11. inf = rtGetInfF();
  12. } else {
  13. union {
  14. LittleEndianIEEEDouble bitVal;
  15. real_T fltVal;
  16. } tmpVal;
  17. tmpVal.bitVal.words.wordH = 0x7FF00000U;
  18. tmpVal.bitVal.words.wordL = 0x00000000U;
  19. inf = tmpVal.fltVal;
  20. }
  21. return inf;
  22. }
  23. real32_T rtGetInfF(void)
  24. {
  25. IEEESingle infF;
  26. infF.wordL.wordLuint = 0x7F800000U;
  27. return infF.wordL.wordLreal;
  28. }
  29. real_T rtGetMinusInf(void)
  30. {
  31. size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
  32. real_T minf = 0.0;
  33. if (bitsPerReal == 32U) {
  34. minf = rtGetMinusInfF();
  35. } else {
  36. union {
  37. LittleEndianIEEEDouble bitVal;
  38. real_T fltVal;
  39. } tmpVal;
  40. tmpVal.bitVal.words.wordH = 0xFFF00000U;
  41. tmpVal.bitVal.words.wordL = 0x00000000U;
  42. minf = tmpVal.fltVal;
  43. }
  44. return minf;
  45. }
  46. real32_T rtGetMinusInfF(void)
  47. {
  48. IEEESingle minfF;
  49. minfF.wordL.wordLuint = 0xFF800000U;
  50. return minfF.wordL.wordLreal;
  51. }