]> www.ginac.de Git - cln.git/blob - src/float/misc/cl_F_epsneg.cc
Initial revision
[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 "cl_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 // Bei Floats mit d Bits (incl. Hiddem Bit, also d = ?F_mant_len+1)
21 // ist ?F_negative_epsilon = 2^(-d-1)*(1+2^(1-d)),
22 // d.h. Mantisse 10...01, Vorzeichen +.
23
24 static const cl_SF SF_negative_epsilon =
25         make_SF(0,SF_exp_mid-SF_mant_len-1,bit(SF_mant_len)+1);
26
27 static const cl_FF FF_negative_epsilon =
28         encode_FF(0,-FF_mant_len-1,bit(FF_mant_len)+1);
29
30 static const cl_DF DF_negative_epsilon =
31         #if (cl_word_size==64)
32           encode_DF(0,-DF_mant_len-1,bit(DF_mant_len)+1);
33         #else
34           encode_DF(0,-DF_mant_len-1,bit(DF_mant_len-32),1);
35         #endif
36
37 inline const cl_LF LF_negative_epsilon (uintC len)
38 {
39         var Lfloat erg = allocate_lfloat(len,LF_exp_mid-intDsize*(uintL)len,0);
40         var uintD* ptr = &TheLfloat(erg)->data[0];
41         #if CL_DS_BIG_ENDIAN_P
42           *ptr++ = bit(intDsize-1);
43           ptr = clear_loop_up(ptr,len-2);
44           *ptr = bit(0);
45         #else
46           *ptr++ = bit(0);
47           ptr = clear_loop_up(ptr,len-2);
48           *ptr = bit(intDsize-1);
49         #endif
50         return erg;
51 }
52
53 const cl_F float_negative_epsilon (cl_float_format_t f)
54 {
55         floatformatcase((uintL)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 CL_PROVIDE_END(cl_F_epsneg)