]> www.ginac.de Git - cln.git/blob - src/real/misc/cl_R_as.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / real / misc / cl_R_as.cc
1 // cl_R_As().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/real.h"
8
9
10 // Implementation.
11
12 #include "base/cl_N.h"
13
14 namespace cln {
15
16 // Cf. cl_R_p in cl_R_ring.cc.
17 // But here, for better inlining in g++, it is preferrable to finish every
18 // alternative with either "return true;" or "return false;".
19
20 inline bool cl_R_p (const cl_number& x)
21 {
22         if (!x.pointer_p())
23                 switch (x.nonpointer_tag()) {
24                 case cl_FN_tag:
25                 case cl_SF_tag:
26                 #if defined(CL_WIDE_POINTERS)
27                 case cl_FF_tag:
28                 #endif
29                         return true;
30                 }
31         else
32                 if (x.pointer_type()->flags & cl_class_flags_subclass_real)
33                         return true;
34         return false;
35 }
36
37 const cl_R& cl_R_As (const cl_number& x, const char * filename, int line)
38 {
39         if (cl_R_p(x)) {
40                 DeclareType(cl_R,x);
41                 return x;
42         } else
43                 throw as_exception(x,"a real number",filename,line);
44 }
45
46 }  // namespace cln