Double.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2020-09-04
  7. *
  8. * */
  9. #ifndef LS_STD_DOUBLE_HPP
  10. #define LS_STD_DOUBLE_HPP
  11. #include "../base/Class.hpp"
  12. #include "IBoxing.hpp"
  13. namespace ls_std {
  14. class Double : public Class, IBoxing {
  15. public:
  16. Double();
  17. explicit Double(double _value);
  18. ~Double() = default;
  19. // conversion operator
  20. operator double() const; // do not make explicit!
  21. // assignment operators
  22. Double& operator=(double _value);
  23. // arithmetic operators
  24. double operator-() const;
  25. double operator+(const Double& _double) const;
  26. double operator+(double _value) const;
  27. double operator*(const Double& _double) const;
  28. double operator*(double _value) const;
  29. double operator-(const Double& _double) const;
  30. double operator-(double _value) const;
  31. double operator/(const Double& _double) const;
  32. double operator/(double _value) const;
  33. // compound operators
  34. Double& operator+=(const Double& _double);
  35. Double& operator+=(double _value);
  36. Double& operator-=(const Double& _double);
  37. Double& operator-=(double _value);
  38. Double& operator*=(const Double& _double);
  39. Double& operator*=(double _value);
  40. Double& operator/=(const Double& _double);
  41. Double& operator/=(double _value);
  42. // comparison operators
  43. bool operator==(const Double& _double) const;
  44. bool operator==(double _value) const;
  45. bool operator!=(const Double& _double) const;
  46. bool operator!=(double _value) const;
  47. bool operator>(const Double& _double) const;
  48. bool operator>(double _value) const;
  49. bool operator>=(const Double& _double) const;
  50. bool operator>=(double _value) const;
  51. bool operator<(const Double& _double) const;
  52. bool operator<(double _value) const;
  53. bool operator<=(const Double& _double) const;
  54. bool operator<=(double _value) const;
  55. // increment / decrement operator
  56. void operator++();
  57. void operator--();
  58. // implementation
  59. void parse(std::string _parseText) override;
  60. std::string toString() override;
  61. // additional functionality
  62. double getEpsilon();
  63. double getValue();
  64. void setEpsilon(double _epsilon);
  65. private:
  66. double value {};
  67. double epsilon {};
  68. };
  69. }
  70. #endif