(******************************************************************************
*                                FIXED11 .DEF                                 *
*                              ABO Software Dep.                              *
*                                                                             *
* Purpose : Fixed point maths routines                                        *
*                                                                             *
*                                                                             *
*                                                                             *
*   Notes :                                                                   *
*                                                                             *
*                                                                             *
*                                                                             *
*         Version Date : 19/02/93                                             *
******************************************************************************)
DEFINITION MODULE FIXED1;

CONST
	ONE = 2147483648.0;
TYPE

Fixed = RECORD
	CASE :BOOLEAN OF
		|TRUE : v  :LONGINT;
		|FALSE: l,h:INTEGER;
	END;
END;

VAR


INLINE PROCEDURE add(a,b : Fixed):Fixed ; BEGIN RETURN(Fixed(a.v+b.v)) END add;
INLINE PROCEDURE sub(a,b : Fixed):Fixed ; BEGIN RETURN(Fixed(a.v-b.v)) END sub;
INLINE PROCEDURE mult(a,b : Fixed):Fixed ;BEGIN RETURN(Fixed((LONGINT(a.h)*LONGINT(b.h))<<1 )) END mult;
INLINE PROCEDURE div (a,b : Fixed):Fixed ;BEGIN RETURN(Fixed((a.v DIV LONGINT(b.h)) <<15 )) END div;
INLINE PROCEDURE neg(a : Fixed):Fixed;BEGIN RETURN(Fixed(-a.v)) END neg;
INLINE PROCEDURE fix2real(a:Fixed):REAL;BEGIN RETURN(VAL(REAL,a.v)/ONE) END fix2real;
INLINE PROCEDURE real2fix(r:REAL):Fixed;BEGIN RETURN(Fixed(VAL(LONGINT,r*ONE))) END real2fix;
PROCEDURE WrFixed(a:Fixed);

END FIXED1.