Template class for the emulation. More...
#include <floating_point_emulation.hpp>
Public Types | |
enum | { shift = S } |
enum | { factor = 1 << S } |
typedef T | value_type |
Public Member Functions | |
tfloat () | |
tfloat (const int value) | |
tfloat (const double value) | |
tfloat & | operator= (const tfloat rhs) |
tfloat & | operator= (const int rhs) |
tfloat & | operator= (const double rhs) |
bool | operator< (const tfloat rhs) const |
bool | operator<= (const tfloat rhs) const |
bool | operator> (const tfloat rhs) const |
bool | operator>= (const tfloat rhs) const |
bool | operator== (const tfloat rhs) const |
bool | operator== (const int rhs) const |
bool | operator== (const double rhs) const |
bool | operator!= (const tfloat rhs) const |
bool | operator!= (const int rhs) const |
bool | operator!= (const double rhs) const |
bool | operator! () const |
tfloat | operator- () const |
tfloat | operator+ () const |
tfloat & | operator*= (const tfloat rhs) |
Multiply. More... | |
tfloat & | operator*= (const int rhs) |
Multiply. More... | |
tfloat & | operator*= (const double rhs) |
Multiply. More... | |
tfloat & | operator/= (const tfloat rhs) |
Divide. More... | |
tfloat & | operator/= (const int rhs) |
Divide. More... | |
tfloat & | operator/= (const double rhs) |
Divide. More... | |
tfloat & | operator+= (const tfloat rhs) |
tfloat & | operator+= (const int rhs) |
tfloat & | operator+= (const double rhs) |
tfloat & | operator-= (const tfloat rhs) |
tfloat & | operator-= (const int rhs) |
tfloat & | operator-= (const double rhs) |
int | to_int () const |
double | to_double () const |
int | floor () |
T | get_value () const |
template<> | |
tfloat< Sint32, 8 > & | operator*= (const tfloat< Sint32, 8 > rhs) |
Private Member Functions | |
tfloat & | negative () |
Changes the object to its negative value. More... | |
Private Attributes | |
T | value_ |
The value of the emulation. More... | |
Friends | |
template<class TT , unsigned SS> | |
struct | detail::tidiv |
Template class for the emulation.
explicit
for conversion operators and the implicit conversion is evil.T | The type used for the emulation. At the moment the following types are supported:
|
Definition at line 143 of file floating_point_emulation.hpp.
typedef T floating_point_emulation::tfloat< T, S >::value_type |
Definition at line 584 of file floating_point_emulation.hpp.
anonymous enum |
Enumerator | |
---|---|
shift |
Definition at line 586 of file floating_point_emulation.hpp.
anonymous enum |
Enumerator | |
---|---|
factor |
Definition at line 587 of file floating_point_emulation.hpp.
|
inline |
Definition at line 591 of file floating_point_emulation.hpp.
Referenced by floating_point_emulation::tfloat< T, S >::operator+=(), floating_point_emulation::tfloat< T, S >::operator-(), floating_point_emulation::tfloat< T, S >::operator-=(), floating_point_emulation::tfloat< T, S >::operator=(), and floating_point_emulation::tfloat< T, S >::operator==().
|
inlineexplicit |
Definition at line 596 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK.
|
inlineexplicit |
Definition at line 602 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK.
|
inline |
Definition at line 897 of file floating_point_emulation.hpp.
References floating_point_emulation::floor(), and floating_point_emulation::tfloat< T, S >::value_.
Referenced by floating_point_emulation::floor(), and test_floor().
|
inline |
Definition at line 905 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inlineprivate |
Changes the object to its negative value.
There is an issue with operator-(). There is an constructor that takes value_type as parameter. When shift != 0 the issue occurs. Implementing operator-() as return tfloat(-value_) returns a scaled value. Scaling twice might loose resolution and cause some overhead. So just add this function to solve the issue.
*this
, but it's value is negated. Definition at line 933 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 701 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 676 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator==().
|
inline |
Definition at line 682 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator==().
|
inline |
Definition at line 688 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator==().
|
inline |
Multiply.
Keep in mind that:
THIS * RHS = this * sf * rhs * sf = result * sf * sf = RESULT * sf
Thus in order to get RESULT there needs to be divided by sf:
RESULT = THIS * RHS / sf
Definition at line 735 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Multiply.
No extra adjustment needed since:
RESULT = THIS * rhs
Definition at line 758 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Multiply.
No extra adjustment needed since:
RESULT = THIS * rhs
Definition at line 773 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Specialized for the Sint32 with a shift of 8.
Instead of figuring out the optimal shift before multiplying simply multiply as a 64-bit value and then perform the shift. This is rather cheap on the Pandora and also keeps the code short on that platform (only two extra instructions on the ARM v7; a `logical shift right' instruction followed by a `logical left shifted or' instruction.)
Definition at line 988 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 713 of file floating_point_emulation.hpp.
|
inline |
Definition at line 839 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
Referenced by floating_point_emulation::tfloat< T, S >::operator+=().
|
inline |
Definition at line 847 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator+=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 853 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator+=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 707 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 861 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
Referenced by floating_point_emulation::tfloat< T, S >::operator-=().
|
inline |
Definition at line 869 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator-=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 875 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator-=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Divide.
Keep in mind that:
THIS * RHS = this * sf * rhs * sf = result * sf * sf = RESULT * sf
THIS this * sf this -— = ------— = -— = result RHS rhs * sf rhs
Thus in order to get RESULT there needs to be multiplied by sf:
THIS
RESULT = -— * sf RHS
Definition at line 800 of file floating_point_emulation.hpp.
References floating_point_emulation::detail::tidiv< T, S >::idiv().
|
inline |
Divide.
No extra adjustment needed since:
RESULT = THIS / rhs
Definition at line 813 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Divide.
No extra adjustment needed since:
RESULT = THIS / rhs
Definition at line 828 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 632 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 638 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 610 of file floating_point_emulation.hpp.
References FLOATING_POINT_EMULATION_RANGE_CHECK, and floating_point_emulation::tfloat< T, S >::value_.
Referenced by floating_point_emulation::tfloat< T, S >::operator=().
|
inline |
Definition at line 618 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 624 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator=(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 657 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
Referenced by floating_point_emulation::tfloat< T, S >::operator!=(), and floating_point_emulation::tfloat< T, S >::operator==().
|
inline |
Definition at line 663 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator==(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 669 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::operator==(), and floating_point_emulation::tfloat< T, S >::tfloat().
|
inline |
Definition at line 644 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 650 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
|
inline |
Definition at line 889 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
Referenced by test_to_double().
|
inline |
Definition at line 883 of file floating_point_emulation.hpp.
References floating_point_emulation::tfloat< T, S >::value_.
Referenced by scale_surface_sharp(), and test_to_int().
Definition at line 579 of file floating_point_emulation.hpp.
|
private |
The value of the emulation.
What the value represents is not really defined for the user.
Definition at line 919 of file floating_point_emulation.hpp.
Referenced by floating_point_emulation::tfloat< T, S >::floor(), floating_point_emulation::tfloat< T, S >::get_value(), floating_point_emulation::detail::tidiv< T, S >::idiv(), floating_point_emulation::detail::tidiv< T, 8 >::idiv(), floating_point_emulation::tfloat< T, S >::negative(), floating_point_emulation::tfloat< T, S >::operator!(), floating_point_emulation::tfloat< T, S >::operator*=(), floating_point_emulation::tfloat< T, S >::operator+=(), floating_point_emulation::tfloat< T, S >::operator-=(), floating_point_emulation::tfloat< T, S >::operator/=(), floating_point_emulation::tfloat< T, S >::operator<(), floating_point_emulation::tfloat< T, S >::operator<=(), floating_point_emulation::tfloat< T, S >::operator=(), floating_point_emulation::tfloat< T, S >::operator==(), floating_point_emulation::tfloat< T, S >::operator>(), floating_point_emulation::tfloat< T, S >::operator>=(), floating_point_emulation::tfloat< T, S >::to_double(), and floating_point_emulation::tfloat< T, S >::to_int().