]> www.ginac.de Git - cln.git/blob - src/rational/misc/cl_RA_as.cc
* include/cln/number.h (As): Fix it in namespace by suffixing `_As'
[cln.git] / src / rational / misc / cl_RA_as.cc
1 // cl_RA_As().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/rational.h"
8
9
10 // Implementation.
11
12 #include "cl_N.h"
13
14 namespace cln {
15
16 // Cf. cl_RA_p in cl_RA_ring.cc.
17 // But here, for better inlining in g++, it is preferrable to finish every
18 // alternative with either "return cl_true;" or "return cl_false;".
19
20 inline cl_boolean cl_RA_p (const cl_number& x)
21 {
22         if (!x.pointer_p())
23                 switch (x.nonpointer_tag()) {
24                 case cl_FN_tag:
25                         return cl_true;
26                 }
27         else
28                 if (x.pointer_type()->flags & cl_class_flags_subclass_rational)
29                         return cl_true;
30         return cl_false;
31 }
32
33 const cl_RA& cl_RA_As (const cl_number& x, const char * filename, int line)
34 {
35         if (cl_RA_p(x)) {
36                 DeclareType(cl_RA,x);
37                 return x;
38         } else
39                 cl_as_error(x,"a rational number",filename,line);
40 }
41
42 }  // namespace cln