]> www.ginac.de Git - cln.git/blob - src/rational/misc/cl_RA_expt.cc
d65f8d6cce9b3e07efd2be7b6d9af500033e28c2
[cln.git] / src / rational / misc / cl_RA_expt.cc
1 // expt().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_rational.h"
8
9
10 // Implementation.
11
12 const cl_RA expt (const cl_RA& x, sintL y)
13 {
14 // Methode:
15 // Für y>0: klar.
16 // Für y=0: Ergebnis 1.
17 // Für y<0: (/ (expt x (- y))).
18         if (y > 0)
19                 return expt_pos(x,(uintL)y);
20         elif (y == 0)
21                 return 1;
22         else // y < 0
23                 return recip(expt_pos(x,(uintL)(-y)));
24 }