Double.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2020-08-16
  7. *
  8. * */
  9. #include <cmath>
  10. #include "Double.hpp"
  11. ls_std::Double::Double() : Class("Double"),
  12. epsilon(0.00000001)
  13. {}
  14. ls_std::Double::Double(double _value) : Class("Double"),
  15. epsilon(0.00000001),
  16. value(_value)
  17. {}
  18. ls_std::Double::operator double() const {
  19. return this->value;
  20. }
  21. ls_std::Double & ls_std::Double::operator=(double _value) {
  22. this->value = _value;
  23. return *this;
  24. }
  25. double ls_std::Double::operator-() const {
  26. return -this->value;
  27. }
  28. double ls_std::Double::operator+(const Double &_double) const {
  29. return this->value + _double;
  30. }
  31. double ls_std::Double::operator+(double _value) const {
  32. return this->value + _value;
  33. }
  34. double ls_std::Double::operator*(const Double &_double) const {
  35. return this->value * _double;
  36. }
  37. double ls_std::Double::operator*(double _value) const {
  38. return this->value * _value;
  39. }
  40. double ls_std::Double::operator-(const Double &_double) const {
  41. return this->value - _double;
  42. }
  43. double ls_std::Double::operator-(double _value) const {
  44. return this->value - _value;
  45. }
  46. double ls_std::Double::operator/(const Double &_double) const {
  47. return this->value / _double;
  48. }
  49. double ls_std::Double::operator/(double _value) const {
  50. return this->value / _value;
  51. }
  52. ls_std::Double & ls_std::Double::operator+=(const Double &_double) {
  53. this->value += _double;
  54. return *this;
  55. }
  56. ls_std::Double & ls_std::Double::operator+=(double _value) {
  57. this->value += _value;
  58. return *this;
  59. }
  60. ls_std::Double & ls_std::Double::operator-=(const Double &_double) {
  61. this->value -= _double;
  62. return *this;
  63. }
  64. ls_std::Double & ls_std::Double::operator-=(double _value) {
  65. this->value -= _value;
  66. return *this;
  67. }
  68. ls_std::Double & ls_std::Double::operator*=(const Double &_double) {
  69. this->value *= _double;
  70. return *this;
  71. }
  72. ls_std::Double & ls_std::Double::operator*=(double _value) {
  73. this->value *= _value;
  74. return *this;
  75. }
  76. ls_std::Double & ls_std::Double::operator/=(const Double &_double) {
  77. this->value /= _double;
  78. return *this;
  79. }
  80. ls_std::Double & ls_std::Double::operator/=(double _value) {
  81. this->value /= _value;
  82. return *this;
  83. }
  84. bool ls_std::Double::operator==(const Double &_double) const {
  85. return std::fabs(this->value - _double) < this->epsilon;
  86. }
  87. bool ls_std::Double::operator==(double _value) const {
  88. return std::fabs(this->value - _value) < this->epsilon;
  89. }
  90. bool ls_std::Double::operator!=(const Double &_double) const {
  91. return std::fabs(this->value - _double) >= this->epsilon;
  92. }
  93. bool ls_std::Double::operator!=(double _value) const {
  94. return std::fabs(this->value - _value) >= this->epsilon;
  95. }
  96. bool ls_std::Double::operator>(const Double &_double) const {
  97. return this->value > _double;
  98. }
  99. bool ls_std::Double::operator>(double _value) const {
  100. return this->value > _value;
  101. }
  102. bool ls_std::Double::operator>=(const Double &_double) const {
  103. return this->value >= _double;
  104. }
  105. bool ls_std::Double::operator>=(double _value) const {
  106. return this->value >= _value;
  107. }
  108. bool ls_std::Double::operator<(const Double &_double) const {
  109. return this->value < _double;
  110. }
  111. bool ls_std::Double::operator<(double _value) const {
  112. return this->value < _value;
  113. }
  114. bool ls_std::Double::operator<=(const Double &_double) const {
  115. return this->value <= _double;
  116. }
  117. bool ls_std::Double::operator<=(double _value) const {
  118. return this->value <= _value;
  119. }
  120. void ls_std::Double::operator++() {
  121. this->value += 1.0f;
  122. }
  123. void ls_std::Double::operator--() {
  124. this->value -= 1.0f;
  125. }
  126. void ls_std::Double::parse(std::string _parseText) {
  127. this->value = std::stod(_parseText);
  128. }
  129. std::string ls_std::Double::toString() {
  130. return std::to_string(this->value);
  131. }
  132. double ls_std::Double::getEpsilon() {
  133. return this->epsilon;
  134. }
  135. double ls_std::Double::getValue() {
  136. return this->value;
  137. }
  138. void ls_std::Double::setEpsilon(double _epsilon) {
  139. this->epsilon = _epsilon;
  140. }