]> www.ginac.de Git - cln.git/blob - src/float/misc/cl_F_leastneg.cc
5f31488f0e9f1f0943f2dae04f05d02badc91bcd
[cln.git] / src / float / misc / cl_F_leastneg.cc
1 // least_negative_float().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 CL_PROVIDE(cl_F_leastneg)
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 // Exponent so klein wie möglich, Mantisse 10...0, Vorzeichen -.
21
22 static const cl_SF least_negative_SF =
23         make_SF(-1,SF_exp_low,bit(SF_mant_len));
24
25 static const cl_FF least_negative_FF =
26         encode_FF(-1,FF_exp_low-FF_exp_mid,bit(FF_mant_len));
27
28 static const cl_DF least_negative_DF =
29         #if (cl_word_size==64)
30           encode_DF(-1,DF_exp_low-DF_exp_mid,bit(DF_mant_len));
31         #else
32           encode_DF(-1,DF_exp_low-DF_exp_mid,bit(DF_mant_len-32),0);
33         #endif
34
35 inline const cl_LF least_negative_LF (uintC len)
36 {
37         var Lfloat erg = allocate_lfloat(len,LF_exp_low,-1);
38         #if CL_DS_BIG_ENDIAN_P
39           TheLfloat(erg)->data[0] = bit(intDsize-1);
40           clear_loop_up(&TheLfloat(erg)->data[1],len-1);
41         #else
42           var uintD* ptr = clear_loop_up(&TheLfloat(erg)->data[0],len-1);
43           *ptr = bit(intDsize-1);
44         #endif
45         return erg;
46 }
47
48 const cl_F least_negative_float (cl_float_format_t f)
49 {
50         floatformatcase((uintL)f
51         ,       return least_negative_SF;
52         ,       return least_negative_FF;
53         ,       return least_negative_DF;
54         ,       return least_negative_LF(len);
55         );
56 }
57
58 CL_PROVIDE_END(cl_F_leastneg)