floatspc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. {
  26. #endif
  27. typedef union _u08
  28. {
  29. unsigned char value;
  30. } _08;
  31. typedef union _u16
  32. {
  33. struct
  34. {
  35. #if CPU_ENDIAN_BIG
  36. _08 high08, low08;
  37. #else
  38. _08 low08, high08;
  39. #endif
  40. } s;
  41. unsigned short value;
  42. } _16;
  43. typedef union _u32
  44. {
  45. struct
  46. {
  47. #if CPU_ENDIAN_BIG
  48. _16 high16, low16;
  49. #else
  50. _16 low16, high16;
  51. #endif
  52. } s;
  53. uint32_t value;
  54. } _32;
  55. typedef struct
  56. {
  57. _32 i32;
  58. } _rtl_float_t;
  59. int isnan_f(void *_f);
  60. /*长整数快速开根号*/
  61. unsigned short sqrt_16(uint32_t x);
  62. float sqrt_32f(uint32_t x);
  63. /*浮点数快速开根号*/
  64. float sqrt_f(float x);
  65. DWORD sqrt_32fix(DWORD x);
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif