From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!ucbcad!ucbvax!IBM.COM!NCOHEN From: NCOHEN@IBM.COM (Norman COHEN) Newsgroups: comp.lang.ada Subject: Ko_Haw Nieh's floating-point formatting problem Message-ID: <111087.123944.ncohen@ibm.com> Date: Sat, 14-Nov-87 19:56:55 EST Article-I.D.: ibm.111087.123944.ncohen Posted: Sat Nov 14 19:56:55 1987 Date-Received: Sun, 15-Nov-87 20:28:35 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet List-Id: There is no way to achieve the effect Ko-Haw Nieh desires using the versions of Put provided by instances of Text_IO.Float_IO. Those versions allow two different styles of real output, ordinary notation and scientific notation. Ordinary notation results from an EXP value of zero. Thus Put (23.35, Fore => f, Aft => a, Exp => 0); produces output of the form b...b23.350...0 \ / \ / min(f,2) a where the value for FORE affects the number of leading blanks and the value for AFT affects the number of digits printed after the decimal point. A nonzero value of EXP results in scientific notation. Some people define scientific notation to include one significant digit before the decimal point and others define it with the most signficant digit immediately to the right of the decimal point. The designers of Ada subscribe to the first definition; the designers of Ko-Haw Nieh's FORTRAN compiler apparently subscribe to the second. In Ada, the call Put (23.35, Fore => f, Aft => a, Exp => e); -- e>0 produces output of the following form: b...b2.3350...0E+0...01 \ / \ / \ / min(f,1) a min(e,2) FORE controls only the number of leading blanks, AFT controls only the number of digits following the decimal point and preceding the E, and EXP controls only the number of characters (including the sign) following the E. There is no way to control the number of significant digits that appear before the decimal point. It is, of course, possible--with some work--to write one's own version of Put based on the other definition of scientific notation, or to write a version with an additional parameter to control the number of significant digits that will appear before the decimal point when exponential notation is used.