From: Sam Moore Date: Fri, 11 Apr 2014 09:31:41 +0000 (+0800) Subject: Remove REAL_HALF as it doesn't actually implement a half precision float X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9fb7c94d259a623a5cad36f8ccb6f8a49f21cf52;p=ipdf%2Fcode.git 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... --- 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();