如何在 gfortran 中获取 sizeof double
how to get sizeof double in gfortran
print *, sizeof(DOUBLE)
给我 4
DOUBLE PRECISION x
print *, sizeof(x)
给我 8(我认为是正确的)
不幸的是,这不会编译:
print *, "size of DOUBLE:", sizeof(DOUBLE PRECISION)
有没有办法在一次 sizeof() 调用中实现这一点?
sizeof
是 GNU 扩展,因此不一定可移植。
The argument shall be of any type, rank or shape.
因此以下工作:
program test
print *,sizeof(1.d0)
end program
1.d0
是双精度文字。要获取单精度浮点数的大小,请使用 1.e0
或 1.
。
print *, sizeof(DOUBLE)
给我 4
DOUBLE PRECISION x
print *, sizeof(x)
给我 8(我认为是正确的)
不幸的是,这不会编译:
print *, "size of DOUBLE:", sizeof(DOUBLE PRECISION)
有没有办法在一次 sizeof() 调用中实现这一点?
sizeof
是 GNU 扩展,因此不一定可移植。
The argument shall be of any type, rank or shape.
因此以下工作:
program test
print *,sizeof(1.d0)
end program
1.d0
是双精度文字。要获取单精度浮点数的大小,请使用 1.e0
或 1.
。