[Fortran] 纯文本查看 复制代码
program test_precision
use, intrinsic :: iso_fortran_env
implicit none
integer, parameter :: sp = REAL32
integer, parameter :: dp = REAL64
integer, parameter :: qp = REAL128
real(kind = sp) :: x1 = 0.0
real(kind = dp) :: x2 = 0.0
real(kind = qp) :: x3 = 0.0
write(*,'(A,I4,A,G0,A,I6)') "Max number in ", sp*8, " bits = ", huge(x1), " Max power to e= ", floor(log(huge(x1)))
write(*,'(A,I4,A,G0,A,I6)') "Max number in ", dp*8, " bits = ", huge(x2), " Max power to e= ", floor(log(huge(x2)))
write(*,'(A,I4,A,G0,A,I6)') "Max number in ", qp*8, " bits = ", huge(x3), " Max power to e= ", floor(log(huge(x3)))
end program test_precision