nieh@moose.steinmetz (nico nieh) (11/06/87)
In FORTRAN, the free format output of 23.35 is 0.2335000+02. I just discovered that there is no way to let Ada print out 23.35 as 0.2335000+02. I tried AFT and EXP control parameters and I always got 2.335000+01. Do I miss something? Can any one out there tell me what's wrong? Thanks in advance. Ko-Haw Nieh General Electric Company Corporate Research and Development nieh@ge-crd.arpa 518-387-7431
stt@ada-uts (11/08/87)
This is a feature, not a bug. Ada believes in "scientific notation" (not "Fortran notation"). As it says in LRM 14.3.8:14, If EXP has a value greater than zero, then the integer part to be output has a *single* digit, which is nonzero except for the value 0.0 of ITEM. If you feel adventurous, you can PUT the number into a string, and then fiddle around with the string (probably easiest if you multiply by 10 first, so all you have to do is prepend "0." and eliminate the existing decimal point). If you feel very adventurous, you can write your own Float-to-string conversion routine, and then output it using PUT of a string. Tucker Taft c/o Intermetrics Cambridge, MA 02138
Alfred.Peterson@SEI.CMU.EDU (11/11/87)
>In FORTRAN, the free format output of 23.35 is 0.2335000+02. >I just discovered that there is no way to let Ada print out 23.35 >as 0.2335000+02. I tried AFT and EXP control parameters and I always got >2.335000+01. Do I miss something? Can any one out there tell me >what's wrong? Thanks in advance. > Ko-Haw Nieh > General Electric Company > Corporate Research and Development > nieh@ge-crd.arpa > 518-387-7431 Yes, unfortunately, Text_Io is REQUIRED to behave as you specify above. ARM 14.3.8 (Input-Output for Real Types) para. 13 states "If EXP has the value zero, then the integer part to be output has as many digits as are needed to represent the integer part of the value of ITEM [in the overloaded procedures PUT above], overriding FORE if necessary, or consists of the digit zero if the value of ITEM has no integer part." The next paragrah states "If EXP has a value greater than zero, then the integer part to be output has a single digit, which is nonzero except for the value 0.0 of ITEM." The ramification of the two paragraphs is that the predefined Text_Io package can NEVER produce the output that you would like and be validable. I believe that the premise for the required Text_Io format is that it follows that of the 'standard' scientific notation form for writing real numbers. Spencer Peterson Member of the Technical Staff Software Engineering Institute Carnegie Mellon University Pittsburgh, PA 15213 412-269-7608 asp@sei.cmu.edu