diff options
-rw-r--r-- | src/m_fixed.c | 41 | ||||
-rw-r--r-- | src/m_fixed.h | 1 |
2 files changed, 13 insertions, 29 deletions
diff --git a/src/m_fixed.c b/src/m_fixed.c index 970394a6..5e3050bc 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -52,34 +52,19 @@ FixedMul // FixedDiv, C version. // -fixed_t -FixedDiv -( fixed_t a, - fixed_t b ) +fixed_t FixedDiv(fixed_t a, fixed_t b) { - if ( (abs(a)>>14) >= abs(b)) - return (a^b)<0 ? INT_MIN : INT_MAX; - return FixedDiv2 (a,b); + if ((abs(a) >> 14) >= abs(b)) + { + return (a^b) < 0 ? INT_MIN : INT_MAX; + } + else + { + long long result; + + result = ((long long) a << 16) / b; + + return (fixed_t) result; + } } - - -fixed_t -FixedDiv2 -( fixed_t a, - fixed_t b ) -{ -#if 0 - long long c; - c = ((long long)a<<16) / ((long long)b); - return (fixed_t) c; -#endif - - double c; - - c = ((double)a) / ((double)b) * FRACUNIT; - - if (c >= 2147483648.0 || c < -2147483648.0) - I_Error("FixedDiv: divide by zero"); - return (fixed_t) c; -} diff --git a/src/m_fixed.h b/src/m_fixed.h index 6a676c31..56a716d4 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -41,7 +41,6 @@ typedef int fixed_t; fixed_t FixedMul (fixed_t a, fixed_t b); fixed_t FixedDiv (fixed_t a, fixed_t b); -fixed_t FixedDiv2 (fixed_t a, fixed_t b); |