Path: utzoo!attcan!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!p101.f4.n494.z5.fidonet.org!Pat.Terry From: Pat.Terry@p101.f4.n494.z5.fidonet.org (Pat Terry) Newsgroups: comp.lang.modula2 Subject: FST bug Message-ID: <90.27366ED3@puddle.fidonet.org> Date: 6 Nov 90 05:14:00 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 5:494/4.101 - Settler City Fido, Grahamstown RSA Lines: 31 There is a slight bug in the FST 2.0 RealConversions module. It does not round negative values correctly. Better code would be as follows For the LONGREAL bit PROCEDURE putRealF( x :REAL; nd, n :INTEGER ); VAR neg :BOOLEAN; d :ARRAY [0..MaxMantDigs] OF CHAR; i :INTEGER; decAt, int :INTEGER; BEGIN IF n < nd+2 THEN ok := FALSE; RETURN END; n := n - (nd+2); * IF x >= 0.0 * THEN x := x + SHORT(5.0/TenTo(nd+1)); (* round *) * ELSE x := x - SHORT(5.0/TenTo(nd+1)); (* round *) END; and for the REAL bit * IF x >= 0.0 * THEN x := x + 5.0/TenTo(nd+1); (* round *) * ELSE x := x - 5.0/TenTo(nd+1); (* round *) * END; -- uucp: uunet!m2xenix!puddle!5!494!4.101!Pat.Terry Internet: Pat.Terry@p101.f4.n494.z5.fidonet.org