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.

66 lines
2.1 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Concrete class of long float numbers.
  2. #ifndef _CL_LFLOAT_CLASS_H
  3. #define _CL_LFLOAT_CLASS_H
  4. #include "cln/number.h"
  5. #include "cln/float_class.h"
  6. namespace cln {
  7. class cl_LF : public cl_F {
  8. public:
  9. // Default constructor.
  10. cl_LF ();
  11. // Assignment operators.
  12. cl_LF& operator= (const cl_LF&);
  13. // Optimization of method pointer_p().
  14. bool pointer_p() const
  15. { return true; }
  16. // Faster pointer_p() gives a faster copy constructor (but not destructor!!!).
  17. cl_LF (const cl_LF& x);
  18. // Other constructors.
  19. cl_LF (const char *);
  20. // Private constructor.
  21. cl_LF (cl_private_thing);
  22. cl_LF (struct cl_heap_lfloat *);
  23. // Private pointer manipulations.
  24. operator struct cl_heap_lfloat * () const;
  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, void* ptr) { (void)size; return ptr; }
  28. void operator delete (void* ptr) { free_hook(ptr); }
  29. };
  30. // Define this if you want the elementary cl_LF operations (+, -, *, /,
  31. // sqrt, cl_LF_I_mul) to return results which are always the correctly
  32. // rounded exact results, i.e. results which are correct within 0.5 ulp.
  33. // If you don't define this, results will be correct within 0.50001 ulp,
  34. // but often the computation will be much faster.
  35. /* #define CL_LF_PEDANTIC */
  36. // Private constructors.
  37. inline cl_LF::cl_LF (cl_private_thing ptr) : cl_F (ptr) {}
  38. // The assignment operators:
  39. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_LF, cl_LF)
  40. // The default constructors.
  41. // Private pointer manipulations. Never throw away a `struct cl_heap_lfloat *'!
  42. inline cl_LF::operator struct cl_heap_lfloat * () const
  43. {
  44. struct cl_heap_lfloat * hpointer = (struct cl_heap_lfloat *) pointer;
  45. cl_inc_refcount(*this);
  46. return hpointer;
  47. }
  48. extern const cl_LF cl_LF_0;
  49. inline cl_LF::cl_LF ()
  50. : cl_F ((cl_private_thing) (struct cl_heap_lfloat *) cl_LF_0) {}
  51. CL_REQUIRE(cl_LF_globals)
  52. #if 0 // see cl_LF_impl.h
  53. inline cl_LF::cl_LF (struct cl_heap_lfloat * ptr)
  54. : cl_F ((cl_private_thing) ptr) {}
  55. #endif
  56. // The copy constructors.
  57. CL_DEFINE_COPY_CONSTRUCTOR2(cl_LF,cl_F)
  58. } // namespace cln
  59. #endif /* _CL_LFLOAT_CLASS_H */