You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

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