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