1 // round2(). 2 3 // General includes. 4 #include "base/cl_sysdep.h" 5 6 // Specification. 7 #include "cln/real.h" 8 9 10 // Implementation. 11 12 #include "real/cl_R.h" 13 #include "cln/rational.h" 14 #include "real/division/cl_R_div_t.h" 15 16 namespace cln { 17 round2(const cl_R & x,const cl_R & y)18const cl_R_div_t round2 (const cl_R& x, const cl_R& y) 19 { 20 // Methode: 21 // Beides rationale Zahlen -> round2(x,y). 22 // Sonst: round2(x/y) -> (q,r). Liefere q und x-y*q=y*r. 23 if (rationalp(x)) 24 if (rationalp(y)) { 25 DeclareType(cl_RA,x); 26 DeclareType(cl_RA,y); 27 return round2(x,y); 28 } 29 var cl_R_div_t q_r = round2(x/y); 30 var cl_I& q = q_r.quotient; 31 var cl_R& r = q_r.remainder; 32 return cl_R_div_t(q,y*r); 33 } 34 35 } // namespace cln 36