diff --git a/src/FixedPoints/SFixed.h b/src/FixedPoints/SFixed.h index 4d93cf7..93e8154 100644 --- a/src/FixedPoints/SFixed.h +++ b/src/FixedPoints/SFixed.h @@ -98,7 +98,18 @@ public: constexpr IntegerType getInteger() const; constexpr FractionType getFraction() const; - constexpr explicit operator IntegerType() const; + constexpr explicit operator char() const; + constexpr explicit operator unsigned char() const; + constexpr explicit operator signed char() const; + constexpr explicit operator unsigned short int() const; + constexpr explicit operator signed short int() const; + constexpr explicit operator unsigned int() const; + constexpr explicit operator signed int() const; + constexpr explicit operator unsigned long int() const; + constexpr explicit operator signed long int() const; + constexpr explicit operator unsigned long long int() const; + constexpr explicit operator signed long long int() const; + constexpr explicit operator float() const; constexpr explicit operator double() const; constexpr explicit operator long double() const; diff --git a/src/FixedPoints/SFixedMemberFunctions.h b/src/FixedPoints/SFixedMemberFunctions.h index 69f35e5..97c57d7 100644 --- a/src/FixedPoints/SFixedMemberFunctions.h +++ b/src/FixedPoints/SFixedMemberFunctions.h @@ -147,11 +147,73 @@ constexpr typename SFixed::FractionType SFixed -constexpr SFixed::operator IntegerType() const +constexpr SFixed::operator char() const { return this->getInteger(); } +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator unsigned char() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator signed char() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator unsigned short int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator signed short int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator unsigned int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator signed int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator unsigned long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator signed long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator unsigned long long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr SFixed::operator signed long long int() const +{ + return this->getInteger(); +} + + + template< unsigned Integer, unsigned Fraction > constexpr SFixed::operator float() const { diff --git a/src/FixedPoints/UFixed.h b/src/FixedPoints/UFixed.h index 4444f55..0ded491 100644 --- a/src/FixedPoints/UFixed.h +++ b/src/FixedPoints/UFixed.h @@ -99,7 +99,18 @@ public: constexpr IntegerType getInteger() const; constexpr FractionType getFraction() const; - constexpr explicit operator IntegerType() const; + constexpr explicit operator char() const; + constexpr explicit operator unsigned char() const; + constexpr explicit operator signed char() const; + constexpr explicit operator unsigned short int() const; + constexpr explicit operator signed short int() const; + constexpr explicit operator unsigned int() const; + constexpr explicit operator signed int() const; + constexpr explicit operator unsigned long int() const; + constexpr explicit operator signed long int() const; + constexpr explicit operator unsigned long long int() const; + constexpr explicit operator signed long long int() const; + constexpr explicit operator float() const; constexpr explicit operator double() const; constexpr explicit operator long double() const; diff --git a/src/FixedPoints/UFixedMemberFunctions.h b/src/FixedPoints/UFixedMemberFunctions.h index 00def81..56b82db 100644 --- a/src/FixedPoints/UFixedMemberFunctions.h +++ b/src/FixedPoints/UFixedMemberFunctions.h @@ -147,11 +147,73 @@ constexpr typename UFixed::FractionType UFixed -constexpr UFixed::operator IntegerType() const +constexpr UFixed::operator char() const { return this->getInteger(); } +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator unsigned char() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator signed char() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator unsigned short int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator signed short int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator unsigned int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator signed int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator unsigned long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator signed long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator unsigned long long int() const +{ + return this->getInteger(); +} + +template< unsigned Integer, unsigned Fraction > +constexpr UFixed::operator signed long long int() const +{ + return this->getInteger(); +} + + + template< unsigned Integer, unsigned Fraction > constexpr UFixed::operator float() const {