Xref: utzoo comp.os.vms:13854 comp.lang.pascal:1759 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bsu-cs!neubauer From: neubauer@bsu-cs.bsu.edu (Paul Neubauer) Newsgroups: comp.os.vms,comp.lang.pascal Subject: Re: VAX Pascal writeln on real numbers Keywords: pascal writeln rounding Message-ID: <6963@bsu-cs.bsu.edu> Date: 27 Apr 89 15:46:49 GMT References: <2744@cps3xx.UUCP> <6953@bsu-cs.bsu.edu> Reply-To: neubauer@bsu-cs.bsu.edu (Paul Neubauer) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 43 In article <6953@bsu-cs.bsu.edu> mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) writes: >In article <2744@cps3xx.UUCP>, rang@cpsin3.cps.msu.edu (Anton Rang) writes: >> I noticed that the rounding on small numbers done by writeln on VAX >> Pascal has a counter-intuitive (to me) result: >> >> writeln(-0.000001:6:4); >> >> ==> "0.0000" > >It's been a while since I have tried anything like this, but it seems to >me that Pascal cannot display the sign since the field is not wide enough. >What you happen if you would try to display the same thing using a field >that was 7 characters wide, still with 4 decimal places? I'd try it myself Sorry, that is not what is going on here. The following short program shows that it always counts 0 as positive and always expands the field width to include everything to the left of the .: PROGRAM Signs (output); BEGIN writeln(-0.000001:6:4); writeln(-0.000001:7:4); writeln(-1.000001:6:4); writeln(-1.000001:7:4); END. {program Signs} The output from this program is: 0.0000 0.0000 -1.0000 -1.0000 That is, the total field width NEVER limits the width. The first width parameter to write[ln] is a LOWER bound to the width. The second width parameter is an UPPER bound. Anton will just have to be satisfied with the fact that zero is zero (at least for present purposes). Some numerical conventions do permit negative zero, but you can't get there from here. -- Paul Neubauer neubauer@bsu-cs.bsu.edu neubauer@bsu-cs.UUCP !{iuvax,pur-ee}!bsu-cs!neubauer