36 #define C4REAL_USE_FIXNUM 1
37 #define inline ALWAYS_INLINE
49 #ifdef C4REAL_USE_FIXNUM
54 #define FIXED_SHIFT 16
56 #define FIXED_FPF int32_t(1 << FIXED_SHIFT)
60 #ifdef C4REAL_USE_FIXNUM
68 friend void FIXED_TO_FLOAT(
float *pVal);
83 explicit inline C4Fixed(int32_t iVal)
86 explicit inline C4Fixed(int32_t iVal, int32_t iPrec)
89 : int32_t( int64_t(iVal) *
FIXED_FPF / iPrec )
92 explicit inline C4Fixed(
float fVal)
97 int32_t to_int()
const
106 int32_t to_int(int32_t prec)
const
115 float to_float()
const
126 explicit operator bool ()
const {
return val != 0; }
142 #ifndef FIXED_EMULATE_64BIT
217 #ifdef C4REAL_USE_FIXNUM
221 int32_t v=int32_t((int64_t(
val)*100)/
FIXED_FPF);
if (v<0) v=18000-v; v%=36000;
236 int32_t v=int32_t((int64_t(
val)*100)/
FIXED_FPF);
if (v<0) v=-v; v%=36000;
252 #ifdef C4REAL_USE_FIXNUM
260 inline int fixtoi(
const C4Fixed &x, int32_t prec) {
return x.to_int(prec); }
290 asm (
"or $1, %0" :
"+rom" (x));
291 asm (
"fistp%z0 %0" :
"=om" (e) :
"t" (x) :
"st");
304 inline C4Real Sin(
C4Real x) {
return float(sin(x * 3.141592f / 180)); }
305 inline C4Real Cos(
C4Real x) {
return float(cos(x * 3.141592f / 180)); }
317 #ifdef C4REAL_USE_FIXNUM
320 *pVal =
ftofix (*
reinterpret_cast<float *
>(pVal));
323 inline void FIXED_TO_FLOAT(
C4Real *pVal)
325 *pVal =
reinterpret_cast<C4Fixed *
>(pVal)->to_float();
float fixtof(const C4Fixed &x)
C4Fixed itofix(int32_t x)
C4Real Cos(const C4Real &fAngle)
int fixtoi(const C4Fixed &x)
void FLOAT_TO_FIXED(C4Real *pVal)
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
C4Real Sin(const C4Real &fAngle)
bool operator>(const C4Fixed &fVal2) const
C4Fixed & operator*=(const C4Fixed &fVal2)
bool operator<(const C4Fixed &fVal2) const
C4Fixed & operator/=(const C4Fixed &fVal2)
bool operator>=(const C4Fixed &fVal2) const
C4Fixed operator*(const C4Fixed &fVal2) const
C4Fixed(const C4Fixed &)=default
friend float fixtof(const C4Fixed &x)
C4Fixed & operator+=(const C4Fixed &fVal2)
friend C4Fixed itofix(int32_t x)
C4Fixed operator-() const
friend int fixtoi(const C4Fixed &x)
friend C4Fixed ftofix(float x)
C4Fixed operator/(const C4Fixed &fVal2) const
friend void CompileFunc(C4Fixed &rValue, StdCompiler *pComp)
C4Fixed & operator=(int32_t x)
C4Fixed & operator-=(const C4Fixed &fVal2)
bool operator==(const C4Fixed &fVal2) const
C4Fixed operator+() const
bool operator!=(const C4Fixed &fVal2) const
bool operator<=(const C4Fixed &fVal2) const