]> www.ginac.de Git - cln.git/blob - src/float/misc/cl_F_epsneg.cc
Fix compilation with GCC 4.4.
[cln.git] / src / float / misc / cl_F_epsneg.cc
1 // float_negative_epsilon().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/float.h"
8
9 // Implementation.
10
11 #include "float/cl_F.h"
12 #include "float/sfloat/cl_SF.h"
13 #include "float/ffloat/cl_FF.h"
14 #include "float/dfloat/cl_DF.h"
15 #include "float/lfloat/cl_LF.h"
16 #include "float/lfloat/cl_LF_impl.h"
17
18 namespace cln {
19
20 static inline const cl_LF LF_negative_epsilon (uintC len)
21 {
22         var Lfloat erg = allocate_lfloat(len,LF_exp_mid-intDsize*len,0);
23         var uintD* ptr = &TheLfloat(erg)->data[0];
24         #if CL_DS_BIG_ENDIAN_P
25           *ptr++ = bit(intDsize-1);
26           ptr = clear_loop_up(ptr,len-2);
27           *ptr = bit(0);
28         #else
29           *ptr++ = bit(0);
30           ptr = clear_loop_up(ptr,len-2);
31           *ptr = bit(intDsize-1);
32         #endif
33         return erg;
34 }
35
36 const cl_F float_negative_epsilon (float_format_t f)
37 {
38         // Bei Floats mit d Bits (incl. Hiddem Bit, also d = ?F_mant_len+1)
39         // ist ?F_negative_epsilon = 2^(-d-1)*(1+2^(1-d)),
40         // d.h. Mantisse 10...01, Vorzeichen +.
41
42         static const cl_SF SF_negative_epsilon =
43                 make_SF(0,SF_exp_mid-SF_mant_len-1,bit(SF_mant_len)+1);
44
45         static const cl_FF FF_negative_epsilon =
46                 encode_FF(0,-FF_mant_len-1,bit(FF_mant_len)+1);
47
48         static const cl_DF DF_negative_epsilon =
49         #if (cl_word_size==64)
50                 encode_DF(0,-DF_mant_len-1,bit(DF_mant_len)+1);
51         #else
52                 encode_DF(0,-DF_mant_len-1,bit(DF_mant_len-32),1);
53         #endif
54
55         floatformatcase((uintC)f
56         ,       return SF_negative_epsilon;
57         ,       return FF_negative_epsilon;
58         ,       return DF_negative_epsilon;
59         ,       return LF_negative_epsilon(len);
60         );
61 }
62
63 }  // namespace cln
64