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
00026
00027
00028
00029
00030
00031
00036 class PG_API pgFix
00037 {
00038 public:
00039 pgDefineException(ExceptionOverflow);
00040 pgDefineException(ExceptionUnderflow);
00041
00045 pgFix();
00046
00051 pgFix(s32 n);
00052
00057 pgFix(r32 r);
00058
00064 bool operator==(pgFix fix) const;
00065
00071 bool operator!=(pgFix fix) const;
00072
00078 bool operator<(pgFix fix) const;
00079
00085 bool operator>(pgFix fix) const;
00086
00092 bool operator<=(pgFix fix) const;
00093
00099 bool operator>=(pgFix fix) const;
00100
00106 pgFix operator+(pgFix fix) const;
00107
00114 PG_API friend pgFix operator+(s32 n, pgFix fix);
00115
00122 PG_API friend pgFix operator+(r32 r, pgFix fix);
00123
00128 void operator+=(pgFix fix);
00129
00134 pgFix operator-() const;
00135
00141 pgFix operator-(pgFix fix) const;
00142
00149 PG_API friend pgFix operator-(s32 n, pgFix fix);
00150
00157 PG_API friend pgFix operator-(r32 r, pgFix fix);
00158
00163 void operator-=(pgFix fix);
00164
00170 pgFix operator*(pgFix fix) const;
00171
00178 PG_API friend pgFix operator*(s32 n, pgFix fix);
00179
00186 PG_API friend pgFix operator*(r32 r, pgFix fix);
00187
00192 void operator*=(pgFix fix);
00193
00199 pgFix operator/(pgFix fix) const;
00200
00207 PG_API friend pgFix operator/(s32 n, pgFix fix);
00208
00215 PG_API friend pgFix operator/(r32 r, pgFix fix);
00216
00221 void operator/=(pgFix fix);
00222
00227 s32 toS32() const;
00228
00233 r32 toR32() const;
00234
00239 s32 getValue() const;
00240
00246 static pgFix fromValue(s32 value);
00247
00248 private:
00249 static const u32 BIT_NUM = 32;
00250 static const u32 FRACTION_BIT_NUM = 16;
00251
00252 static void checkOverflow(s64 value);
00253
00254 s32 m_value;
00255 };