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.

50 lines
1.4 KiB

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