]> www.ginac.de Git - cln.git/blob - src/integer/division/cl_I_trunc1.cc
* configure.ac: Re-enable shared lib on non-MinGW platforms, sigh.
[cln.git] / src / integer / division / cl_I_trunc1.cc
1 // truncate1().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13
14 namespace cln {
15
16 const cl_I truncate1 (const cl_I& x, const cl_I& y)
17 {
18 // Methode:
19 // (truncate x y) :==
20 // (DIVIDE (abs x) (abs y)) -> q,r
21 // Falls x<0, setze r:=-r.
22 // Falls x,y verschiedene Vorzeichen haben, setze q:=-q.
23 // Liefere nur q.
24   var cl_I_div_t q_r = cl_divide(abs(x),abs(y));
25   var cl_I& q = q_r.quotient;
26   if (minusp(x) != minusp(y))
27     { q = -q; }
28   return q;
29 }
30
31 }  // namespace cln