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.

52 lines
1.4 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Abstract class of floating-point numbers.
  2. #ifndef _CL_FLOAT_CLASS_H
  3. #define _CL_FLOAT_CLASS_H
  4. #include "cln/number.h"
  5. #include "cln/real_class.h"
  6. namespace cln {
  7. class cl_F : public cl_R {
  8. public:
  9. // Default constructor.
  10. cl_F ();
  11. // Copy constructor.
  12. cl_F (const cl_F&);
  13. // Converters.
  14. // Assignment operators.
  15. cl_F& operator= (const cl_F&);
  16. // Constructors and assignment operators from C numeric types.
  17. cl_F (const float);
  18. cl_F (const double);
  19. cl_F& operator= (const float);
  20. cl_F& operator= (const double);
  21. // Other constructors.
  22. cl_F (const char *);
  23. // Private constructor.
  24. cl_F (cl_private_thing);
  25. public: // Ability to place an object at a given address.
  26. void* operator new (size_t size) { return malloc_hook(size); }
  27. void* operator new (size_t size, cl_F* ptr) { (void)size; return ptr; }
  28. void operator delete (void* ptr) { free_hook(ptr); }
  29. private:
  30. // Friend declarations. They are for the compiler. Just ignore them.
  31. };
  32. // Private constructors.
  33. inline cl_F::cl_F (cl_private_thing ptr) : cl_R (ptr) {}
  34. // The assignment operators:
  35. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_F, cl_F)
  36. // The default constructors.
  37. inline cl_F::cl_F ()
  38. : cl_R ((cl_private_thing) cl_combine(cl_SF_tag,0)) {}
  39. // The copy constructors.
  40. CL_DEFINE_COPY_CONSTRUCTOR2(cl_F,cl_R)
  41. // Constructors and assignment operators from C numeric types.
  42. CL_DEFINE_FLOAT_CONSTRUCTOR(cl_F)
  43. CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_F)
  44. } // namespace cln
  45. #endif /* _CL_FLOAT_CLASS_H */