1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
18 // Revision 1.2 2002/04/27 09:51:47 hkiel
19 // reversed order of FixedDiv() and helper function FixedDiv2() to avoid
22 // Revision 1.1 2000/02/29 18:21:04 stegerg
23 // Doom port based on ADoomPPC. Read README.AROS!
27 // Fixed point implementation.
29 //-----------------------------------------------------------------------------
41 #pragma implementation "m_fixed.h"
48 // Fixme. __USE_C_FIXED__ or something.
55 return ((long long) a
* (long long) b
) >> FRACBITS
;
61 // FixedDiv, C version.
71 c
= ((long long)a
<<16) / ((long long)b
);
77 c
= ((double)a
) / ((double)b
) * FRACUNIT
;
79 if (c
>= 2147483648.0 || c
< -2147483648.0)
80 I_Error("FixedDiv: divide by zero");
92 if ( (abs(a
)>>14) >= abs(b
))
93 return (a
^b
)<0 ? MININT
: MAXINT
;
94 return FixedDiv2 (a
,b
);