Skip to content

Incorrect display of engineering format #10

@dwannetts

Description

@dwannetts

Hi,

I'm trying to use Julia, and NumericIO in particular, to refactor some Fortran.

Julia's output is

      10000.00     1   -500.00000E0    0.0000000E0    1.0000000E0   -510.00000E0
      10000.00     2   -400.00000E0    0.0000000E0    1.0000000E0   -410.00000E0
      10000.00     3   -300.00000E0    0.0000000E0    1.0000000E0   -310.00000E0
      10000.00     4   -200.00000E0    0.0000000E0    1.0000000E0   -210.00000E0
      10000.00     5   -100.00000E0    0.0000000E0    1.0000000E0   -110.00000E0
      10000.00     6    0.0000000E0    0.0000000E0    1.0000000E0   -10.000000E0
      10000.00     7    100.00000E0    0.0000000E0    1.0000000E0    90.000000E0
      10000.00     8    200.00000E0    0.0000000E0    1.0000000E0    190.00000E0
      10000.00     9    300.00000E0    0.0000000E0    1.0000000E0    290.00000E0
      10000.00    10    400.00000E0    0.0000000E0    1.0000000E0    390.00000E0
      10000.00    11    500.00000E0    0.0000000E0    1.0000000E0    490.00000E0

from the code fragment

oline =  @sprintf("  %12.2f  %4d", line, tndx)
	    s = formatted(txdp.l.e, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')
	    s = formatted(txdp.l.n, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')
	    s = formatted(txdp.l.z, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')
	    s = formatted(rxdp[jr].l.e, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')
	    s = formatted(rxdp[jr].l.n, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')
	    s = formatted(rxdp[jr].l.z, :ENG, ndigits=8, charset=:ASCII); oline *= lpad(s, 15, ' ')

I believe that if engineering format is working correctly, the output should be

      10000.00     1   -500.00000E+00    0.0000000E+00    1.0000000E+00   -510.00000E+00
      10000.00     2   -400.00000E+00    0.0000000E+00    1.0000000E+00   -410.00000E+00
      10000.00     3   -300.00000E+00    0.0000000E+00    1.0000000E+00   -310.00000E+00
      10000.00     4   -200.00000E+00    0.0000000E+00    1.0000000E+00   -210.00000E+00
      10000.00     5   -100.00000E+00    0.0000000E+00    1.0000000E+00   -110.00000E+00
      10000.00     6      0.00000E+00    0.0000000E+00    1.0000000E+00    -10.00000E+00
      10000.00     7    100.00000E+00    0.0000000E+00    1.0000000E+00     90.00000E+00
      10000.00     8    200.00000E+00    0.0000000E+00    1.0000000E+00    190.00000E+00
      10000.00     9    300.00000E+00    0.0000000E+00    1.0000000E+00    290.00000E+00
      10000.00    10    400.00000E+00    0.0000000E+00    1.0000000E+00    390.00000E+00
      10000.00    11    500.00000E+00    0.0000000E+00    1.0000000E+00    490.00000E+00

ie. decimal points should align down the columns as they do in Fortran.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions