floatspc.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*******************************************************
  2. * 版本号: 1.00 版本号
  3. * 文件名: floatspc.c
  4. * 生成日期:2005.11.11
  5. * 作者: 钟振新
  6. ******************************************************/
  7. #ifndef FLOAT_SPECIAL
  8. #define FLOAT_SPECIAL
  9. #ifdef MODE_LITTLE_ENDIAN
  10. #define CPU_ENDIAN_BIG 0
  11. #else
  12. #define CPU_ENDIAN_BIG 1 // 1-大尾格式,用于motorola等cpu
  13. #endif
  14. #define _FPCLASS_SNAN 1
  15. #define _FPCLASS_QNAN 2
  16. #define _FPCLASS_OVER 3
  17. #ifndef FAST
  18. #define FAST
  19. #endif
  20. #ifndef NULL
  21. #define NULL 0
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C"{
  25. #endif
  26. typedef union _u08
  27. {
  28. unsigned char value;
  29. } _08;
  30. typedef union _u16
  31. {
  32. struct
  33. {
  34. #if CPU_ENDIAN_BIG
  35. _08 high08, low08;
  36. #else
  37. _08 low08, high08;
  38. #endif
  39. } s;
  40. unsigned short value;
  41. } _16;
  42. typedef union _u32
  43. {
  44. struct
  45. {
  46. #if CPU_ENDIAN_BIG
  47. _16 high16, low16;
  48. #else
  49. _16 low16, high16;
  50. #endif
  51. } s;
  52. uint32_t value;
  53. } _32;
  54. typedef struct
  55. {
  56. _32 i32;
  57. } _rtl_float_t;
  58. int isnan_f (void *_f);
  59. /*长整数快速开根号*/
  60. unsigned short sqrt_16(uint32_t x);
  61. float sqrt_32f(uint32_t x);
  62. /*浮点数快速开根号*/
  63. float sqrt_f(float x);
  64. DWORD sqrt_32fix(DWORD x);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif