1 /*-------------------------------------------------------------------------
2 float.h - ANSI functions forward declarations
4 Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
29 #ifndef __SDC51_FLOAT_H
30 #define __SDC51_FLOAT_H 1
37 #define FLT_MANT_DIG 24
38 #define FLT_EPSILON 1.192092896E-07F
40 #define FLT_MIN_EXP (-125)
41 #define FLT_MIN 1.175494351E-38F
42 #define FLT_MIN_10_EXP (-37)
43 #define FLT_MAX_EXP (+128)
44 #define FLT_MAX 3.402823466E+38F
45 #define FLT_MAX_10_EXP (+38)
46 #if __STDC_VERSION__ >= 201112L
47 #define FLT_DECIMAL_DIG 9
48 #define FLT_TRUE_MIN 1.175494351E-38F
49 #define FLT_HAS_SUBNORM 0
52 #if __SIZEOF_DOUBLE__ == 4
54 #define DBL_MANT_DIG FLT_MANT_DIG
55 #define DBL_EPSILON FLT_EPSILON
56 #define DBL_DIG FLT_DIG
57 #define DBL_MIN_EXP FLT_MIN_EXP
58 #define DBL_MIN FLT_MIN
59 #define DBL_MIN_10_EXP FLT_MIN_10_EXP
60 #define DBL_MAX_EXP FLT_MAX_EXP
61 #define DBL_MAX FLT_MAX
62 #define DBL_MAX_10_EXP FLT_MAX_10_EXP
63 #if __STDC_VERSION__ >= 201112L
64 #define DBL_DECIMAL_DIG FLT_DECIMAL_DIG
65 #define DBL_TRUE_MIN FLT_TRUE_MIN
66 #define DBL_HAS_SUBNORM FLT_HAS_SUBNORM
71 /* the following deal with IEEE single-precision numbers */
72 #if defined(__SDCC_FLOAT_LIB)
74 #define SIGNBIT ((unsigned long)0x80000000)
75 #define __INFINITY ((unsigned long)0x7F800000)
76 #define __NAN ((unsigned long)0xFFC00000)
77 #define HIDDEN (unsigned long)(1ul << 23)
78 #define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1)
79 #define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF)
80 #define MANT(fp) (((fp) & (unsigned long)0x00FFFFFF) | HIDDEN)
81 #define NORM 0xff000000
82 #define PACK(s,e,m) ((s) | ((unsigned long)(e) << 23) | (m))
85 #define __SDCC_FLOAT_NONBANKED __SDCC_NONBANKED
87 float __uchar2fs (unsigned char) __SDCC_FLOAT_NONBANKED
;
88 float __schar2fs (signed char) __SDCC_FLOAT_NONBANKED
;
89 float __uint2fs (unsigned int) __SDCC_FLOAT_NONBANKED
;
90 float __sint2fs (signed int) __SDCC_FLOAT_NONBANKED
;
91 float __ulong2fs (unsigned long) __SDCC_FLOAT_NONBANKED
;
92 float __slong2fs (signed long) __SDCC_FLOAT_NONBANKED
;
93 #ifdef __SDCC_LONGLONG
94 float __ulonglong2fs (unsigned long long) __SDCC_FLOAT_NONBANKED
;
95 float __slonglong2fs (signed long long) __SDCC_FLOAT_NONBANKED
;
97 unsigned char __fs2uchar (float) __SDCC_FLOAT_NONBANKED
;
98 signed char __fs2schar (float) __SDCC_FLOAT_NONBANKED
;
99 unsigned int __fs2uint (float) __SDCC_FLOAT_NONBANKED
;
100 signed int __fs2sint (float) __SDCC_FLOAT_NONBANKED
;
101 unsigned long __fs2ulong (float) __SDCC_FLOAT_NONBANKED
;
102 signed long __fs2slong (float) __SDCC_FLOAT_NONBANKED
;
104 float __fsadd (float, float) __SDCC_FLOAT_NONBANKED
;
105 float __fssub (float, float) __SDCC_FLOAT_NONBANKED
;
106 float __fsmul (float, float) __SDCC_FLOAT_NONBANKED
;
107 float __fsdiv (float, float) __SDCC_FLOAT_NONBANKED
;
109 _Bool
__fslt (float, float) __SDCC_FLOAT_NONBANKED
;
110 _Bool
__fseq (float, float) __SDCC_FLOAT_NONBANKED
;
111 _Bool
__fsgt (float, float) __SDCC_FLOAT_NONBANKED
;
114 #if defined(__SDCC_FLOAT_LIB) && defined(__SDCC_mcs51) && !defined(__SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
116 #define FLOAT_ASM_MCS51
118 /* This adds extra code for proper round-off, in
119 an attempt to match the results from gcc. */
120 #define FLOAT_FULL_ACCURACY
122 /* This adds about 66 bytes to the code size and
123 significantly speeds up shift operations more
124 than 8 bits (common when subtracting numbers
125 of significantly different magnitude and scaling
127 #define FLOAT_SHIFT_SPEEDUP
133 #endif /* using mcs51 assembly */
136 #endif /* __SDC51_FLOAT_H */