主题:[讨论]【基本功训练 01】浮点数 与 文件输入问题
近日,我在其它 BBS 上看到有很多资深网友在文件读取 有关 浮点数 的方面很模糊,如下例子可助诸君明白一些概念。
若是谁能直接讲出(不要上机实验)下面程序输入 0.33333, 0.33333E0, 0.33333D0 会发生什么,那您还是个明白人。 再上一个层次,就是能引经据典地给不懂得同志讲讲了。抛砖引玉,方家指正。
program main
implicit none
double precision:: x, y
character(len = 12):: fmt_str
fmt_str = "(D24.16)"
read(unit = *, fmt = *) x ! enter 0.33333, 0.33333E0, 0.33333D0
write(unit = *, fmt = fmt_str) x
y = 0.33333
write(unit = *, fmt = fmt_str) y
stop
end program main
若是谁能直接讲出(不要上机实验)下面程序输入 0.33333, 0.33333E0, 0.33333D0 会发生什么,那您还是个明白人。 再上一个层次,就是能引经据典地给不懂得同志讲讲了。抛砖引玉,方家指正。
program main
implicit none
double precision:: x, y
character(len = 12):: fmt_str
fmt_str = "(D24.16)"
read(unit = *, fmt = *) x ! enter 0.33333, 0.33333E0, 0.33333D0
write(unit = *, fmt = fmt_str) x
y = 0.33333
write(unit = *, fmt = fmt_str) y
stop
end program main