Skip to content

Commit

Permalink
Revert "Verifying that auto comparisons aren't using float casting"
Browse files Browse the repository at this point in the history
This reverts commit 2cac79a.
  • Loading branch information
saxbophone committed Sep 14, 2021
1 parent 2cac79a commit c20baca
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sxpsxfp/include/sxpsxfp/Fixed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <sys/types.h>
#endif

#include <limits>

namespace com::saxbophone::sxpsxfp {
class Fixed; // forward-declaration to allow declaration of user-defined literals

Expand Down Expand Up @@ -134,8 +132,7 @@ namespace com::saxbophone::sxpsxfp {
* floating point support, so slow software floats will be used.
*/
explicit constexpr operator double() const {
// return (double)this->_raw_value / Fixed::SCALE;
return std::numeric_limits<double>::quiet_NaN(); // NaN doesn't compare equal to itself
return (double)this->_raw_value / Fixed::SCALE;
}
/**
* @brief Explicit cast operator to float
Expand All @@ -150,8 +147,7 @@ namespace com::saxbophone::sxpsxfp {
*/
explicit constexpr operator float() const {
// reuse cast to double and then narrow it to float
// return (float)(double)*this;
return std::numeric_limits<float>::quiet_NaN(); // NaN doesn't compare equal to itself
return (float)(double)*this;
}
/**
* @returns Fixed-point value converted to integer, with fractional part truncated.
Expand Down

0 comments on commit c20baca

Please sign in to comment.