Path: utzoo!utgpu!watmath!att!ucbvax!KULING.DOCS.UU.SE!stenake
From: stenake@KULING.DOCS.UU.SE ("Mr Sten-]ke Lindell")
Newsgroups: comp.lang.modula2
Subject: Re: Fixed Point Output with WriteReal
Message-ID: <8908151505.AA06594@kuling.DoCS.UU.SE>
Date: 15 Aug 89 15:05:09 GMT
References: 
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List 
Organization: Dept. of Computer Systems, Uppsala University, Sweden
Lines: 32

In article  you write:
>
>   Hi. I'm a neophyte in Modula-2 and I have a very simple question to
>ask.  Is it possible to get fixed point rather than floating point
>output using WriteReal (a la FORTRAN F6.3 for eg).  The book that
>I'm using now does not mention anything about fixed point output, so
>maybe I'm missing something.  Would appreciate a reply.  Thanks.
>
>Chua KS.

MODULE Gazonk;

FROM InOut IMPORT
   WriteLn, WriteString;

FROM RealConversions IMPORT
   RealToString;

PROCEDURE WriteFix (R : REAL; Dec, Width : CARDINAL);
VAR
   tmpstr : ARRAY [0..80] OF CHAR;
   ok     : BOOLEAN;

BEGIN
   RealToString (R, INTEGER (Dec), INTEGER (Width), tmpstr, ok);
   WriteString (tmpstr)
END WriteFix;

BEGIN
   WriteFix (42.666, 3, 6);
   WriteLn;
END Gazonk.