문제

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.

도움이 되었습니까?

해결책

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

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

다른 팁

Try the P editing format.

write(*,"(A,1PE8.2)") 'X=',x
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top