float.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*-------------------------------------------------------------------------
  2. float.h - ANSI functions forward declarations
  3. Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
  4. This library is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this library; see the file COPYING. If not, write to the
  14. Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  15. MA 02110-1301, USA.
  16. As a special exception, if you link this library with other files,
  17. some of which are compiled with SDCC, to produce an executable,
  18. this library does not by itself cause the resulting executable to
  19. be covered by the GNU General Public License. This exception does
  20. not however invalidate any other reasons why the executable file
  21. might be covered by the GNU General Public License.
  22. -------------------------------------------------------------------------*/
  23. #ifndef __SDC51_FLOAT_H
  24. #define __SDC51_FLOAT_H 1
  25. #include <limits.h>
  26. #define FLT_RADIX 2
  27. #define FLT_MANT_DIG 24
  28. #define FLT_EPSILON 1.192092896E-07F
  29. #define FLT_DIG 6
  30. #define FLT_MIN_EXP (-125)
  31. #define FLT_MIN 1.175494351E-38F
  32. #define FLT_MIN_10_EXP (-37)
  33. #define FLT_MAX_EXP (+128)
  34. #define FLT_MAX 3.402823466E+38F
  35. #define FLT_MAX_10_EXP (+38)
  36. /* the following deal with IEEE single-precision numbers */
  37. #define EXCESS 126
  38. #define SIGNBIT ((unsigned long)0x80000000)
  39. #define __INFINITY ((unsigned long)0x7F800000)
  40. #define HIDDEN (unsigned long)(1ul << 23)
  41. #define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1)
  42. #define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF)
  43. #define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN)
  44. #define NORM 0xff000000
  45. #define PACK(s,e,m) ((s) | ((unsigned long)(e) << 23) | (m))
  46. float __uchar2fs (unsigned char);
  47. float __schar2fs (signed char);
  48. float __uint2fs (unsigned int);
  49. float __sint2fs (signed int);
  50. float __ulong2fs (unsigned long);
  51. float __slong2fs (signed long);
  52. unsigned char __fs2uchar (float);
  53. signed char __fs2schar (float);
  54. unsigned int __fs2uint (float);
  55. signed int __fs2sint (float);
  56. unsigned long __fs2ulong (float);
  57. signed long __fs2slong (float);
  58. float __fsadd (float, float);
  59. float __fssub (float, float);
  60. float __fsmul (float, float);
  61. float __fsdiv (float, float);
  62. char __fslt (float, float);
  63. char __fseq (float, float);
  64. char __fsgt (float, float);
  65. #if defined(__SDCC_FLOAT_LIB) && defined(__SDCC_mcs51) && !defined(__SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
  66. #define FLOAT_ASM_MCS51
  67. /* This adds extra code for proper round-off, in
  68. an attempt to match the results from gcc. */
  69. #define FLOAT_FULL_ACCURACY
  70. /* This adds about 66 bytes to the code size and
  71. significantly speeds up shift operations more
  72. than 8 bits (common when subtracting numbers
  73. of significantly different magnitude and scaling
  74. to fixed point) */
  75. #define FLOAT_SHIFT_SPEEDUP
  76. #define sign_a psw.1
  77. #define sign_b psw.5
  78. #define exp_a dpl
  79. #define exp_b dph
  80. #endif /* using mcs51 assembly */
  81. #endif /* __SDC51_FLOAT_H */