summaryrefslogtreecommitdiff
path: root/src/m_fixed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_fixed.c')
-rw-r--r--src/m_fixed.c41
1 files changed, 13 insertions, 28 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;
-}