#include <ShFraction.hpp>
Public Types | |
typedef ShFractionLongType< T >::type | LongType |
typedef ShFractionSignedLongType< T >::type | SignedLongType |
typedef LongType | CompType |
Public Member Functions | |
ShFraction () | |
Constructs an fraction with undefined value. | |
ShFraction (double value) | |
Constructs an fraction. | |
template<typename T2> | |
ShFraction (const ShFraction< T2 > &other) | |
operator double () const | |
accessor methods * | |
T & | val () |
T | val () const |
ShFraction & | operator= (double value) |
Arithmetic operators *. | |
ShFraction & | operator= (const ShFraction &other) |
ShFraction & | operator+= (double value) |
ShFraction & | operator+= (const ShFraction &other) |
ShFraction & | operator-= (double value) |
ShFraction & | operator-= (const ShFraction &other) |
ShFraction & | operator *= (double value) |
ShFraction & | operator *= (const ShFraction &other) |
ShFraction & | operator/= (double value) |
ShFraction & | operator/= (const ShFraction &other) |
ShFraction & | operator%= (double value) |
Float modulus - result is always positive. | |
ShFraction & | operator%= (const ShFraction &other) |
ShFraction | operator- () const |
Negation *. | |
Static Public Member Functions | |
static ShFraction | make_fraction (CompType value) |
Makes a fraction and clamps from the computation type. | |
static ShFraction | make_fraction_signed (SignedLongType value) |
Makes a fraction and clamps from the signed type. | |
Public Attributes | |
T | m_val |
Static Public Attributes | |
static const bool | is_signed |
static const int | BITS |
number of bits | |
static const T | ONE |
representation of ONE | |
static const T | MAX |
maximum representable value | |
static const T | MIN |
minumum representable value | |
Friends | |
template<typename TT> | |
std::ostream & | operator<< (std::ostream &out, const ShFraction< TT > &value) |
Output operator *. | |
template<typename TT> | |
std::istream & | operator>> (std::istream &out, ShFraction< TT > &value) |
Input operator (format matches output) *. |
All ShFractions are by default clamped. Everything that was commented out has been marked with a
Clamp | whether to clamp to avoid overflow. If this is true, then during computation we always use a temporary type with enough bits to hold the result. If this is false, then we only use temporaries with extra bits if an intermediate value may overflow. If the result itself overflows, then the value stored is implementation defined (wraps around for 2's complement). |
Definition at line 86 of file ShFraction.hpp.