]> www.ginac.de Git - cln.git/blob - src/real/division/cl_R_fceil2.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / real / division / cl_R_fceil2.cc
1 // fceiling2().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/real.h"
8
9
10 // Implementation.
11
12 #include "cl_R.h"
13 #include "cl_R_div_t.h"
14
15 #if 0 // 2 type dispatches
16
17 #include "cln/rational.h"
18 #include "cln/float.h"
19 #include "cl_R_div_t.h"
20
21 namespace cln {
22
23 const cl_R_fdiv_t fceiling2 (const cl_R& x)
24 {
25         if (rationalp(x)) {
26                 DeclareType(cl_RA,x);
27                 var cl_RA_div_t q_r = ceiling2(x);
28                 var cl_I& q = q_r.quotient;
29                 var cl_RA& r = q_r.remainder;
30                 return cl_R_fdiv_t(cl_float(q),r);
31         } else {
32                 DeclareType(cl_F,x);
33                 return fceiling2(x);
34         }
35 }
36
37 }  // namespace cln
38
39 #else // 1 type dispatch
40
41 #include "cl_RA.h"
42 #include "cln/integer.h"
43 #include "cln/sfloat.h"
44 #include "cln/ffloat.h"
45 #include "cln/dfloat.h"
46 #include "cln/lfloat.h"
47 #include "cl_LF.h"
48
49 namespace cln {
50
51 const cl_R_fdiv_t fceiling2 (const cl_R& x)
52 {
53         realcase6(x
54         ,       return cl_R_fdiv_t(cl_float(x),0);
55         ,       var const cl_I& a = numerator(x);
56                 var const cl_I& b = denominator(x);
57                 var cl_I_div_t q_r = ceiling2(a,b);
58                 var cl_I& q = q_r.quotient;
59                 var cl_I& r = q_r.remainder;
60                 return cl_R_fdiv_t(cl_float(q),I_I_to_RT(r,b));
61         ,       var cl_SF q = fceiling(x); return cl_R_fdiv_t(q,x-q);
62         ,       var cl_FF q = fceiling(x); return cl_R_fdiv_t(q,x-q);
63         ,       var cl_DF q = fceiling(x); return cl_R_fdiv_t(q,x-q);
64         ,       var cl_LF q = fceiling(x); return cl_R_fdiv_t(q,LF_LF_minus_LF(x,q));
65         );
66 }
67
68 }  // namespace cln
69
70 #endif