From 9fb7c94d259a623a5cad36f8ccb6f8a49f21cf52 Mon Sep 17 00:00:00 2001 From: Sam Moore Date: Fri, 11 Apr 2014 17:31:41 +0800 Subject: [PATCH] Remove REAL_HALF as it doesn't actually implement a half precision float More to it than just masking bits because the sizes of the exponent differ. Could just mask bits in the mantissa but I have horrible plans involving VFPU... --- .gitignore | 1 + src/real.h | 36 +----------------------------------- src/tests/vfpufloat.cpp | 5 ++++- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 365a631..da6ac03 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.test *.out *.err +*.vcd diff --git a/src/real.h b/src/real.h index 5703671..73aca6d 100644 --- a/src/real.h +++ b/src/real.h @@ -16,41 +16,7 @@ namespace IPDF #elif defined REAL_DOUBLE typedef double Real; inline double Float(Real r) {return r;} -#elif defined REAL_HALF - struct Real - { - Real() = default; - Real(double r) : value(r) - { - int & a = *((int*)(&value)); // um... - // mask out extra bits in exponent - //1000 1111 1000 0000 0000 0011 1111 1111 - // Endianness matters - a &= 0xFFC001F1; //0x8F8003FF; - - } - - Real operator+(float f) const {return Real(value+f);} - Real operator-(float f) const {return Real(value+f);} - Real operator/(float f) const {return Real(value/f);} - Real operator*(float f) const {return Real(value*f);} - Real operator+(const Real & r) const {return Real(this->value + r.value);} - Real operator-(const Real & r) const {return Real(this->value - r.value);} - Real operator*(const Real & r) const {return Real(this->value * r.value);} - Real operator/(const Real & r) const {return Real(this->value / r.value);} - Real & operator+=(const Real & r) {this->value += r.value; return *this;} - Real & operator-=(const Real & r) {this->value -= r.value; return *this;} - Real & operator/=(const Real & r) {this->value /= r.value; return *this;} - Real & operator*=(const Real & r) {this->value *= r.value; return *this;} - - float value; - }; - inline float Float(Real r) {return r.value;} - - inline std::ostream & operator<<(std::ostream & os, Real & r) {return os << r.value;} // yuk - -#endif //REAL_HALF - +#endif } #endif //_REAL_H diff --git a/src/tests/vfpufloat.cpp b/src/tests/vfpufloat.cpp index 5f89a66..dae457b 100644 --- a/src/tests/vfpufloat.cpp +++ b/src/tests/vfpufloat.cpp @@ -6,7 +6,10 @@ using namespace std; int main(int argc, char ** argv) { - VFPU::Start(); + if (argc > 1) + VFPU::Start(argv[1]); + else + VFPU::Start(); float result = VFPU::Exec(25,10, VFPU::SUB); Debug("%f\n", result); VFPU::Halt(); -- 2.20.1