program test
implicit none
integer :: a = 509232994 ! 毫秒数
real :: slope = 0.1
real :: b
b = a *slope
print *, a, b
write (*, fmt = '(F12.1)') b
end program test
program test
implicit none
integer :: a = 509232994 ! 毫秒数
real(kind=8) :: slope = 0.1d0
real(kind=8) :: b
b = a *slope
print *, a, b
write (*, fmt = '(F12.1)') b
end program test
fcode 发表于 2023-12-12 21:10
因为单精度浮点数,只有7位左右的有效位数。你需要双精度。
[mw_shl_code=fortran,true]program test
Transpose 发表于 2023-12-13 09:26
字面值0.1也是有精度的,默认是单精度,0.1d0是双精度
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |