Commit 4e869619 authored by yh2920's avatar yh2920
Browse files

operator overload with float

parent 5ee0fe4f
......@@ -85,18 +85,18 @@ public:
FixedPoint& operator += (int i) {
FixedPoint x = *this;
x += FpF(i);
x += FixedPoint(i);
return x;
}
FixedPoint& operator -= (int i) {
FixedPoint x = *this;
x -= FpF(i);
x -= FixedPoint(i);
return x;
}
FixedPoint& operator *= (int i) {
value *= r;
value *= i;
return *this;
}
......@@ -109,13 +109,13 @@ public:
FixedPoint operator - (int i) const {
FixedPoint x = *this;
x -= r;
x -= i;
return x;
}
FixedPoint operator * (int i) const {
FixedPoint x = *this;
x *= r;
x *= i;
return x;
}
//Binary Operator Overloads
......@@ -124,7 +124,7 @@ public:
}
bool operator != (int i) const{
return !(*this == r);
return !(*this == i);
}
bool operator < (int i) const{
......@@ -144,7 +144,69 @@ public:
return value >= (int) i<<numFracBits;
}
//operator overload with float
FixedPoint& operator += (float f) {
FixedPoint x = *this;
x += FixedPoint(f);
return x;
}
FixedPoint& operator -= (float f) {
FixedPoint x = *this;
x -= FixedPoint(f);
return x;
}
FixedPoint& operator *= (float f) {
FixedPoint x = *this;
x *= FixedPoint(f);
return *this;
}
FixedPoint operator + (float f) const {
FixedPoint x = *this;
x += f;
return x;
}
FixedPoint operator - (float f) const {
FixedPoint x = *this;
x -= f;
return x;
}
FixedPoint operator * (float f) const {
FixedPoint x = *this;
x *= f;
return x;
}
//Binary Operator Overloads
bool operator == (float f) const {
return *this== FixedPoint(f);
}
bool operator != (float f) const{
return !(*this == f);
}
bool operator < (float f) const{
return *this < FixedPoint(f);
}
bool operator > (float f) const{
return *this > FixedPoint(f);
}
bool operator <= (float f) const {
return *this <= FixedPoint(f);
}
bool operator >= (float f) const {
return *this >= FixedPoint(f);
}
int ToInt() const {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment