]> www.ginac.de Git - cln.git/blob - src/integer/division/cl_I_floor1.cc
Use paths relative the `src' directory in the #include directives.
[cln.git] / src / integer / division / cl_I_floor1.cc
1 // floor1().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "integer/cl_I.h"
13
14 namespace cln {
15
16 const cl_I floor1 (const cl_I& x, const cl_I& y)
17 {
18 // Methode:
19 // (floor x y) :==
20 // (DIVIDE (abs x) (abs y)) -> q,r
21 // Falls x,y verschiedene Vorzeichen haben und r<>0,
22 //   setze q:=q+1 und r:=r-abs(y).
23 // Falls x<0, setze r:=-r.
24 // Falls x,y verschiedene Vorzeichen haben, setze q:=-q.
25 // Liefere nur q.
26   var cl_I abs_y = abs(y);
27   var cl_I_div_t q_r = cl_divide(abs(x),abs_y);
28   var cl_I& q = q_r.quotient;
29   var cl_I& r = q_r.remainder;
30   if (minusp(x) != minusp(y)) {
31     if (!zerop(r)) { q = q + 1; }
32     q = -q;
33   }
34   return q;
35 }
36
37 }  // namespace cln