MODULE FP1616;
CONST
FIXPOINT = 65536;
TYPE
PROCEDURE FixpToFloat*(x: LONGINT): REAL;
BEGIN
RETURN (x / FIXPOINT);
END FixpToFloat;
PROCEDURE FloatToFixp*(x: REAL): LONGINT;
BEGIN
IF x > FIXPOINT THEN RETURN FIXPOINT;
ELSIF x < -FIXPOINT THEN RETURN -FIXPOINT
ELSE RETURN ENTIER(x * (FIXPOINT));
END;
END FloatToFixp;
PROCEDURE Int*(fp1616: LONGINT) : LONGINT;
BEGIN
RETURN fp1616 DIV FIXPOINT
END Int;
PROCEDURE Mult*(x, y: LONGINT): LONGINT;
BEGIN
RETURN (ENTIER(FixpToFloat(x)*y));
END Mult;
PROCEDURE Div*(x, y: LONGINT): LONGINT;
BEGIN
RETURN (ENTIER(x/FixpToFloat(y)));
END Div;
END FP1616.