|
|
@ -182,14 +182,33 @@ constexpr SFixed<Integer, Fraction>::operator long double() const |
|
|
|
template< unsigned Integer, unsigned Fraction > |
|
|
|
template< unsigned Integer, unsigned Fraction > |
|
|
|
template< unsigned IntegerOut, unsigned FractionOut > |
|
|
|
template< unsigned IntegerOut, unsigned FractionOut > |
|
|
|
constexpr SFixed<Integer, Fraction>::operator SFixed<IntegerOut, FractionOut>() const |
|
|
|
constexpr SFixed<Integer, Fraction>::operator SFixed<IntegerOut, FractionOut>() const |
|
|
|
{
|
|
|
|
{ |
|
|
|
using OutputType = SFixed<IntegerOut, FractionOut>; |
|
|
|
using OutputType = SFixed<IntegerOut, FractionOut>; |
|
|
|
using OutputInternalType = typename OutputType::InternalType; |
|
|
|
using OutputInternalType = typename OutputType::InternalType; |
|
|
|
using OutputShiftType = typename OutputType::ShiftType; |
|
|
|
using OutputShiftType = typename OutputType::ShiftType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using InputType = SFixed<Integer, Fraction>; |
|
|
|
|
|
|
|
using InputShiftType = typename InputType::ShiftType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
(FractionOut > FractionSize) ? |
|
|
|
|
|
|
|
OutputType::fromInternal(static_cast<OutputInternalType>(static_cast<OutputShiftType>(this->value) << ((FractionOut > FractionSize) ? (FractionOut - FractionSize) : 0))) : |
|
|
|
|
|
|
|
(FractionSize > FractionOut) ? |
|
|
|
|
|
|
|
OutputType::fromInternal(static_cast<OutputInternalType>(static_cast<InputShiftType>(this->value) >> ((FractionSize > FractionOut) ? (FractionSize - FractionOut) : 0))) : |
|
|
|
|
|
|
|
OutputType::fromInternal(this->value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template< unsigned Integer, unsigned Fraction > |
|
|
|
|
|
|
|
template< unsigned IntegerOut, unsigned FractionOut > |
|
|
|
|
|
|
|
constexpr SFixed<Integer, Fraction>::operator UFixed<IntegerOut, FractionOut>() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
using OutputType = UFixed<IntegerOut, FractionOut>; |
|
|
|
|
|
|
|
using OutputInternalType = typename OutputType::InternalType; |
|
|
|
|
|
|
|
using OutputShiftType = typename OutputType::ShiftType; |
|
|
|
|
|
|
|
|
|
|
|
using InputType = SFixed<Integer, Fraction>; |
|
|
|
using InputType = SFixed<Integer, Fraction>; |
|
|
|
using InputShiftType = typename InputType::ShiftType; |
|
|
|
using InputShiftType = typename InputType::ShiftType; |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
(FractionOut > FractionSize) ? |
|
|
|
(FractionOut > FractionSize) ? |
|
|
|
OutputType::fromInternal(static_cast<OutputInternalType>(static_cast<OutputShiftType>(this->value) << ((FractionOut > FractionSize) ? (FractionOut - FractionSize) : 0))) : |
|
|
|
OutputType::fromInternal(static_cast<OutputInternalType>(static_cast<OutputShiftType>(this->value) << ((FractionOut > FractionSize) ? (FractionOut - FractionSize) : 0))) : |
|
|
|