diff --git a/src/FixedPoints/SFixed.h b/src/FixedPoints/SFixed.h index 04ad53b..9576cbe 100644 --- a/src/FixedPoints/SFixed.h +++ b/src/FixedPoints/SFixed.h @@ -74,6 +74,7 @@ public: constexpr explicit operator IntegerType(void) const; constexpr explicit operator float(void) const; constexpr explicit operator double(void) const; + constexpr explicit operator long double(void) const; template< unsigned IntegerOut, unsigned FractionOut > constexpr explicit operator SFixed(void) const; diff --git a/src/FixedPoints/SFixedMemberFunctions.h b/src/FixedPoints/SFixedMemberFunctions.h index aa8b3b9..82848f4 100644 --- a/src/FixedPoints/SFixedMemberFunctions.h +++ b/src/FixedPoints/SFixedMemberFunctions.h @@ -71,7 +71,7 @@ constexpr SFixed::operator IntegerType(void) const template< unsigned Integer, unsigned Fraction > constexpr SFixed::operator float(void) const { - return (1.0f / Scale) * + return (1.0F / Scale) * static_cast ((this->value & IdentityMask) | ((this->value < 0) ? ~IdentityMask : 0)); @@ -86,6 +86,15 @@ constexpr SFixed::operator double(void) const ((this->value < 0) ? ~IdentityMask : 0)); } +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator long double(void) const +{ + return (1.0L / Scale) * + static_cast + ((this->value & IdentityMask) | + ((this->value < 0) ? ~IdentityMask : 0)); +} + template< unsigned Integer, unsigned Fraction > template< unsigned IntegerOut, unsigned FractionOut > constexpr SFixed::operator SFixed(void) const diff --git a/src/FixedPoints/UFixed.h b/src/FixedPoints/UFixed.h index 3becdf5..600eee5 100644 --- a/src/FixedPoints/UFixed.h +++ b/src/FixedPoints/UFixed.h @@ -74,6 +74,7 @@ public: constexpr explicit operator IntegerType(void) const; constexpr explicit operator float(void) const; constexpr explicit operator double(void) const; + constexpr explicit operator long double(void) const; template< unsigned IntegerOut, unsigned FractionOut > constexpr explicit operator UFixed(void) const; diff --git a/src/FixedPoints/UFixedMemberFunctions.h b/src/FixedPoints/UFixedMemberFunctions.h index 55429cd..0b6faae 100644 --- a/src/FixedPoints/UFixedMemberFunctions.h +++ b/src/FixedPoints/UFixedMemberFunctions.h @@ -71,7 +71,7 @@ constexpr UFixed::operator IntegerType(void) const template< unsigned Integer, unsigned Fraction > constexpr UFixed::operator float(void) const { - return ((this->value & IdentityMask) * (1.0f / Scale)); + return ((this->value & IdentityMask) * (1.0F / Scale)); } template< unsigned Integer, unsigned Fraction > @@ -80,6 +80,12 @@ constexpr UFixed::operator double(void) const return ((this->value & IdentityMask) * (1.0 / Scale)); } +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator long double(void) const +{ + return ((this->value & IdentityMask) * (1.0L / Scale)); +} + template< unsigned Integer, unsigned Fraction > template< unsigned IntegerOut, unsigned FractionOut > constexpr UFixed::operator UFixed(void) const