Domanda

Using scientific format in output file, I get: 0.245E+02 instead of 2.45E+01.

How to output in the later format in Fortran?

x = 2.45
write(*,130) 'x=', x
130 format (A,E8.2)

Update: According to @Bálint Aradi's answer, I should have set x = 24.5 in order to get 2.45E+01.

È stato utile?

Soluzione

You should use the "scientific exponential" (ES) format:

x = 2.45
write(*, "(A,ES8.2)") "X=", x

Altri suggerimenti

Try the P editing format.

write(*,"(A,1PE8.2)") 'X=',x
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top