Re: Any suggestion for code to format REAL in a narrow column?



On Feb 14, 4:46 am, "n...@xxxxxxxxxxxxxxx" <n...@xxxxxxxxxxxxxxx>
wrote:
....
In writing F.77 (eg. VAX-Fortran), I'd like to output a REAL*4 value
into a column of 6 characters width.
I also have a supplied INTEGER value ("decno") that states "the
number of decimals", eg it is ment to be formatted like F6.<decno>,
but as You guess there might be a problem. For example, for decno=3,
the output is only fine when -10 < value < 100.

In the general case, this holds, but... when something goes out of the
normal, I'd prefere to squece the value in anyhow! First, I'm
reducing on the number of decimals used, secondly, I'm reverting to
using exponential form.
....
As I'd like to maximize the number of valid figures presented anyhow,
I'd like to note that:

123E11 Has more information than 1.2E13
....

In the Bettis Labs-written nuclear design codes of ages gone by, there
was an input/output processor that made the tacit assumption all
floating point values were written as (for example) 123456-3 where the
decimal and E were implied. The decimal was implied as leading so the
example is 0.000123456. It also had the ability to parse input
containing properly specified I,E, or F formatted values, but I gather
only output is significant here.

I think this is about the most concise generic format possible once
one selects a field width. Switching around between formats from entry
to entry makes reading the output very painful and error prone so
perhaps the occasional loss of a character of precision might be made
up for by fewer mistaken interpretations?

Whether these routines are available or not I don't know--I never saw
the source, but had the functionality available as linkable modules on
machines of days of yore...I know most if not all the codes have been
ported to desktops, but I've not used one in more years than I care to
remember... :)

Anyway, hopefully at least the idea is of some help...
--

.