]> www.ginac.de Git - cln.git/blob - src/integer/division/cl_I_trunc1.cc
08f22058594d729709f8a82dde31982f1b247431
[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 "cl_integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13
14 const cl_I truncate1 (const cl_I& x, const cl_I& y)
15 {
16 // Methode:
17 // (truncate x y) :==
18 // (DIVIDE (abs x) (abs y)) -> q,r
19 // Falls x<0, setze r:=-r.
20 // Falls x,y verschiedene Vorzeichen haben, setze q:=-q.
21 // Liefere nur q.
22   var cl_I_div_t q_r = cl_divide(abs(x),abs(y));
23   var cl_I& q = q_r.quotient;
24   if (minusp(x) != minusp(y))
25     { q = -q; }
26   return q;
27 }