fixed: add to_integral, from_native
This commit is contained in:
parent
f688d8adda
commit
496991f46e
20
fixed.cpp
20
fixed.cpp
@ -68,6 +68,26 @@ fixed<INT, FRAC>::to_native (void) const
|
||||
{ return m_value; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <unsigned INT, unsigned FRAC>
|
||||
fixed<INT,FRAC>
|
||||
fixed<INT,FRAC>::from_native (integral_type i)
|
||||
{
|
||||
fixed<INT,FRAC> out (integral_type {0u});
|
||||
out.m_value = i;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <unsigned INT, unsigned FRAC>
|
||||
typename fixed<INT,FRAC>::integral_type
|
||||
fixed<INT,FRAC>::to_integral (integral_type v)
|
||||
{
|
||||
return v >> FRAC;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Integral operators
|
||||
*/
|
||||
|
@ -43,6 +43,10 @@ namespace util {
|
||||
integral_type to_integral (void) const;
|
||||
combined_type to_native (void) const;
|
||||
|
||||
static fixed<INT,FRAC> from_native (integral_type);
|
||||
|
||||
static integral_type to_integral (integral_type);
|
||||
|
||||
fixed<INT, FRAC>& operator +=(const fixed<INT, FRAC>);
|
||||
fixed<INT, FRAC>& operator -=(const fixed<INT, FRAC>);
|
||||
fixed<INT, FRAC>& operator *=(const fixed<INT, FRAC>);
|
||||
|
Loading…
Reference in New Issue
Block a user