brendanarnold / py-fortranformat

MIT License
31 stars 8 forks source link

Fx.0 format cannot work #17

Closed Kayya886 closed 2 years ago

Kayya886 commented 3 years ago

method _compose_float_string() in file _output.py (line: 219) this fix will cause error .write method output of a FotranFormatWritter('Fx.0')
if (d == 0): return '' w

blaylockbk commented 2 years ago

Hi @brendanarnold, I'm running into this same bug.

In FORTRAN when I format a float with 0 precision, like "f6.0", I get the number with a decimal with no trailing numbers.

Example:

program printformat
implicit none

    real :: number

    number = 99999.01

    Print "(f6.0)", number

end program printformat

OUT: 
99999.

But in Python with fortranformt when I try the same formatting, I get ******

from fortranformat import FortranRecordWriter
record_line = FortranRecordWriter("f6.0")
record_line.write([99999.01])

OUT:
'******'
brendanarnold commented 2 years ago

Which version are you using? I've tried to recreate locally and it seems to work

image

brendanarnold commented 2 years ago

Sorry, my bad that test was actually after I had applied some local changes - verified a bug

brendanarnold commented 2 years ago

Fix is now in 1.1.0