Float.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_FLOAT_HPP
  10. #define LS_STD_FLOAT_HPP
  11. #include "../base/Class.hpp"
  12. #include "IBoxing.hpp"
  13. namespace ls_std {
  14. class Float : public Class, IBoxing {
  15. public:
  16. Float();
  17. explicit Float(float _value);
  18. ~Float() = default;
  19. // conversion operator
  20. operator float() const; // do not make explicit!
  21. // assignment operators
  22. Float& operator=(float _value);
  23. // arithmetic operators
  24. float operator-() const;
  25. float operator+(const Float& _float) const;
  26. float operator+(float _value) const;
  27. float operator*(const Float& _float) const;
  28. float operator*(float _value) const;
  29. float operator-(const Float& _float) const;
  30. float operator-(float _value) const;
  31. float operator/(const Float& _float) const;
  32. float operator/(float _value) const;
  33. // compound operators
  34. Float& operator+=(const Float& _float);
  35. Float& operator+=(float _value);
  36. Float& operator-=(const Float& _float);
  37. Float& operator-=(float _value);
  38. Float& operator*=(const Float& _float);
  39. Float& operator*=(float _value);
  40. Float& operator/=(const Float& _float);
  41. Float& operator/=(float _value);
  42. // comparison operators
  43. bool operator==(const Float& _float) const;
  44. bool operator==(float _value) const;
  45. bool operator!=(const Float& _float) const;
  46. bool operator!=(float _value) const;
  47. bool operator>(const Float& _float) const;
  48. bool operator>(float _value) const;
  49. bool operator>=(const Float& _float) const;
  50. bool operator>=(float _value) const;
  51. bool operator<(const Float& _float) const;
  52. bool operator<(float _value) const;
  53. bool operator<=(const Float& _float) const;
  54. bool operator<=(float _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. float getEpsilon();
  63. float getValue();
  64. void setEpsilon(float _epsilon);
  65. private:
  66. float value {};
  67. float epsilon {};
  68. };
  69. }
  70. #endif