00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHHALF_HPP
00028 #define SHHALF_HPP
00029
00030 #include <limits>
00031 #include "ShUtility.hpp"
00032
00033 namespace SH {
00034
00035 struct ShHalf {
00036 typedef unsigned short T;
00037
00038 static const int S = 1 << 15;
00039 static const int E = 1 << 10;
00040
00041 T m_val;
00042
00044 ShHalf();
00045
00047 ShHalf(double value);
00048
00049 operator double() const;
00050
00052 ShHalf& operator=(double value);
00053 ShHalf& operator=(const ShHalf& other);
00054 ShHalf& operator+=(double value);
00055 ShHalf& operator+=(const ShHalf& other);
00056 ShHalf& operator-=(double value);
00057 ShHalf& operator-=(const ShHalf& other);
00058 ShHalf& operator*=(double value);
00059 ShHalf& operator*=(const ShHalf& other);
00060 ShHalf& operator/=(double value);
00061 ShHalf& operator/=(const ShHalf& other);
00062
00065 ShHalf& operator%=(double value);
00066 ShHalf& operator%=(const ShHalf& other);
00067
00068
00070 ShHalf operator-() const;
00071
00073 friend std::ostream& operator<<(std::ostream& out, const ShHalf &value);
00074
00075
00077 friend std::istream& operator>>(std::istream& out, ShHalf &value);
00078
00079 private:
00081 static ShHalf make_half(T value);
00082
00083 static T to_val(double value);
00084 void set_val(double value);
00085 double get_double() const;
00086 };
00087
00088 }
00089
00090 #include "ShHalfImpl.hpp"
00091
00092 #endif