diff --git a/src/m_fixed.h b/src/m_fixed.h
index 94bd6a16bbf86e70c4f38c86a4758424da325db1..4e644c9b6d5db3687a211526e3a50a5f03e9702f 100644
--- a/src/m_fixed.h
+++ b/src/m_fixed.h
@@ -34,6 +34,7 @@
 */
 
 typedef INT32 fixed_t;
+typedef UINT32 ufixed_t;
 
 /*!
   \brief convert fixed_t into floating number
@@ -106,7 +107,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a)
 */
 FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b)
 {
-	if ((abs(a) >> (FRACBITS-2)) >= abs(b))
+	if (((ufixed_t)abs(a) >> (FRACBITS-2)) >= (ufixed_t)abs(b))
 		return (a^b) < 0 ? INT32_MIN : INT32_MAX;
 
 	return FixedDiv2(a, b);
diff --git a/src/r_main.c b/src/r_main.c
index 0cfccab8c2fbcbd7cdc35c678c379cdfb942cbcc..25d68be66dd952c2d6c7bc8e28272fb0456ce197 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -356,7 +356,7 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
 fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1)
 {
 	angle_t angle;
-	fixed_t dx, dy, dist;
+	ufixed_t dx, dy, dist;
 
 	dx = abs(px1 - px2);
 	dy = abs(py1 - py2);