]> www.ginac.de Git - cln.git/blob - src/rational/misc/cl_RA_expt_I.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / rational / misc / cl_RA_expt_I.cc
1 // expt().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/rational.h"
8
9
10 // Implementation.
11
12 #include "cln/integer.h"
13 #include "cl_I.h"
14
15 namespace cln {
16
17 const cl_RA expt (const cl_RA& x, const cl_I& y)
18 {
19 // Methode:
20 // Für y>0: klar.
21 // Für y=0: Ergebnis 1.
22 // Für y<0: (/ (expt x (- y))).
23         if (minusp(y))
24                 return recip(expt_pos(x,-y));
25         elif (zerop(y))
26                 return 1;
27         else // y > 0
28                 return expt_pos(x,y);
29 }
30
31 }  // namespace cln