|
@ -27,7 +27,7 @@ public: |
|
|
|
|
|
|
|
|
template<class srcT> |
|
|
template<class srcT> |
|
|
constexpr Q (const srcT value) |
|
|
constexpr Q (const srcT value) |
|
|
: backend{(integer_type)(value*(1<<degen))} |
|
|
|
|
|
|
|
|
: backend{(integer_type)(value*(p">((integer_type)1)<<degen))} |
|
|
{} |
|
|
{} |
|
|
|
|
|
|
|
|
constexpr Q () |
|
|
constexpr Q () |
|
@ -43,7 +43,7 @@ public: |
|
|
|
|
|
|
|
|
constexpr bool is_negative() |
|
|
constexpr bool is_negative() |
|
|
{ |
|
|
{ |
|
|
return backend&(1<<(sizeof(backend)-1)); |
|
|
|
|
|
|
|
|
return backend&(p">((integer_type)1)<<(sizeof(backend)-1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +71,7 @@ public: |
|
|
|
|
|
|
|
|
constexpr Q<integer_type, fractionals>& operator/=(const Q& oth) |
|
|
constexpr Q<integer_type, fractionals>& operator/=(const Q& oth) |
|
|
{ |
|
|
{ |
|
|
backend*=1<<Q<integer_type, fractionals>::degen; |
|
|
|
|
|
|
|
|
backend*=p">((integer_type)1)<<Q<integer_type, fractionals>::degen; |
|
|
backend/=oth.backend; |
|
|
backend/=oth.backend; |
|
|
return *this; |
|
|
return *this; |
|
|
} |
|
|
} |
|
@ -145,14 +145,14 @@ public: |
|
|
constexpr operator float() |
|
|
constexpr operator float() |
|
|
{ |
|
|
{ |
|
|
float n=backend; |
|
|
float n=backend; |
|
|
n/=(1<<Q<integer_type, fractionals>::degen); |
|
|
|
|
|
|
|
|
n/=(p">((integer_type)1)<<Q<integer_type, fractionals>::degen); |
|
|
return n; |
|
|
return n; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
constexpr operator double() |
|
|
constexpr operator double() |
|
|
{ |
|
|
{ |
|
|
double n=backend; |
|
|
double n=backend; |
|
|
n/=(1<<Q<integer_type, fractionals>::degen); |
|
|
|
|
|
|
|
|
n/=(p">((integer_type)1)<<Q<integer_type, fractionals>::degen); |
|
|
return n; |
|
|
return n; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|