diff --git a/src/math/pifixedpoint.h b/src/math/pifixedpoint.h index 589bed34..1054f814 100644 --- a/src/math/pifixedpoint.h +++ b/src/math/pifixedpoint.h @@ -20,25 +20,27 @@ along with this program. If not, see . */ +#include "picout.h" + #ifndef PIFIXEDPOINT_H #define PIFIXEDPOINT_H template -class FixedPoint { +class PIFixedPoint { // friend PICout operator <<(PICout s, const FixedPoint<> & v); public: - typedef FixedPoint fp; - FixedPoint(const Type &v = Type()) {val = fpv(v);} - FixedPoint(const fp &v) {val = v.val;} - FixedPoint(const float &v) {val = Precision == 0 ? Type(v) : Type(v * (2 << Precision-1));} - FixedPoint(const double &v) {val = Precision == 0 ? Type(v) : Type(v * (2 << Precision-1));} + typedef PIFixedPoint fp; + PIFixedPoint(const Type &v = Type()) {val = fpv(v);} + PIFixedPoint(const fp &v) {val = v.val;} + PIFixedPoint(const float &v) {val = Precision == 0 ? Type(v) : Type(v * (2 << Precision-1));} + PIFixedPoint(const double &v) {val = Precision == 0 ? Type(v) : Type(v * (2 << Precision-1));} // FixedPoint(const long double &v) {val = Precision == 0 ? Type(v) : Type(v * (2 << Precision-1));} template fp & operator=(const T & v) {val = fpv(Type(v)); return *this;} fp & operator=(const fp & v) {val = v.val; return *this;} - fp & operator=(const float &v) {val = FixedPoint(v).val; return *this;} - fp & operator=(const double &v) {val = FixedPoint(v).val; return *this;} - fp & operator=(const long double &v) {val = FixedPoint(v).val; return *this;} + fp & operator=(const float &v) {val = PIFixedPoint(v).val; return *this;} + fp & operator=(const double &v) {val = PIFixedPoint(v).val; return *this;} + fp & operator=(const long double &v) {val = PIFixedPoint(v).val; return *this;} fp & operator-() {fp p = fp(*this); p.val = -val; return p;} bool operator==(const fp & v) const {val == v.val;} bool operator!=(const fp & v) const {val != v.val;} @@ -73,8 +75,9 @@ public: Type val; }; + template -inline PICout operator <<(PICout s, const FixedPoint & v) { +inline PICout operator <<(PICout s, const PIFixedPoint & v) { s.space(); s.setControl(0, true); if (Precision == 0) s << v.val; else {