1 // Abstract class of rational numbers.
3 #ifndef _CL_RATIONAL_CLASS_H
4 #define _CL_RATIONAL_CLASS_H
6 #include "cln/number.h"
7 #include "cln/real_class.h"
11 class cl_RA : public cl_R {
13 // Default constructor.
18 // Assignment operators.
19 cl_RA& operator= (const cl_RA&);
20 // Constructors and assignment operators from C numeric types.
21 cl_RA (const int); // |argument| must be < 2^29
22 cl_RA (const unsigned int); // argument must be < 2^29
24 cl_RA (const unsigned long);
25 cl_RA (const long long);
26 cl_RA (const unsigned long long);
27 cl_RA& operator= (const int); // |argument| must be < 2^29
28 cl_RA& operator= (const unsigned int); // argument must be < 2^29
29 cl_RA& operator= (const long);
30 cl_RA& operator= (const unsigned long);
31 cl_RA& operator= (const long long);
32 cl_RA& operator= (const unsigned long long);
33 // Other constructors.
35 // Private constructor.
36 cl_RA (cl_private_thing);
37 cl_RA (struct cl_heap_ratio *);
38 public: // Ability to place an object at a given address.
39 void* operator new (size_t size) { return malloc_hook(size); }
40 void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
41 void operator delete (void* ptr) { free_hook(ptr); }
43 // Friend declarations. They are for the compiler. Just ignore them.
46 // Private constructors.
47 inline cl_RA::cl_RA (cl_private_thing ptr) : cl_R (ptr) {}
48 // The assignment operators:
49 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_RA, cl_RA)
50 // The default constructors.
51 inline cl_RA::cl_RA ()
52 : cl_R ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
53 // The copy constructors.
54 CL_DEFINE_COPY_CONSTRUCTOR2(cl_RA,cl_R)
55 // Constructors and assignment operators from C numeric types.
56 CL_DEFINE_INT_CONSTRUCTORS(cl_RA)
57 CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_RA)
58 CL_DEFINE_LONG_CONSTRUCTORS(cl_RA)
59 CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_RA)
60 CL_DEFINE_LONGLONG_CONSTRUCTORS(cl_RA)
61 CL_DEFINE_LONGLONG_ASSIGNMENT_OPERATORS(cl_RA)
65 #endif /* _CL_RATIONAL_CLASS_H */