]> www.ginac.de Git - cln.git/blob - include/cln/rational_class.h
Extend the exponent range from 32 bits to 64 bits on selected platforms.
[cln.git] / include / cln / rational_class.h
1 // Abstract class of rational numbers.
2
3 #ifndef _CL_RATIONAL_CLASS_H
4 #define _CL_RATIONAL_CLASS_H
5
6 #include "cln/number.h"
7 #include "cln/real_class.h"
8
9 namespace cln {
10
11 class cl_RA : public cl_R {
12 public:
13 // Default constructor.
14         cl_RA ();
15 // Copy constructor.
16         cl_RA (const cl_RA&);
17 // Converters.
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
23         cl_RA (const long);
24         cl_RA (const unsigned long);
25 #ifdef HAVE_LONGLONG
26         cl_RA (const long long);
27         cl_RA (const unsigned long long);
28 #endif
29         cl_RA& operator= (const int);           // |argument| must be < 2^29
30         cl_RA& operator= (const unsigned int);  // argument must be < 2^29
31         cl_RA& operator= (const long);
32         cl_RA& operator= (const unsigned long);
33 #ifdef HAVE_LONGLONG
34         cl_RA& operator= (const long long);
35         cl_RA& operator= (const unsigned long long);
36 #endif
37 // Other constructors.
38         cl_RA (const char *);
39 // Private constructor.
40         cl_RA (cl_private_thing);
41         cl_RA (struct cl_heap_ratio *);
42 public: // Ability to place an object at a given address.
43         void* operator new (size_t size) { return malloc_hook(size); }
44         void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
45         void operator delete (void* ptr) { free_hook(ptr); }
46 private:
47 // Friend declarations. They are for the compiler. Just ignore them.
48 };
49
50 // Private constructors.
51 inline cl_RA::cl_RA (cl_private_thing ptr) : cl_R (ptr) {}
52 // The assignment operators:
53 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_RA, cl_RA)
54 // The default constructors.
55 inline cl_RA::cl_RA ()
56         : cl_R ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
57 // The copy constructors.
58 CL_DEFINE_COPY_CONSTRUCTOR2(cl_RA,cl_R)
59 // Constructors and assignment operators from C numeric types.
60 CL_DEFINE_INT_CONSTRUCTORS(cl_RA)
61 CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_RA)
62 CL_DEFINE_LONG_CONSTRUCTORS(cl_RA)
63 CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_RA)
64 #ifdef HAVE_LONGLONG
65 CL_DEFINE_LONGLONG_CONSTRUCTORS(cl_RA)
66 CL_DEFINE_LONGLONG_ASSIGNMENT_OPERATORS(cl_RA)
67 #endif
68
69 }  // namespace cln
70
71 #endif /* _CL_RATIONAL_CLASS_H */