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