例如,
SUBROUTINE DoSomething (Z,L)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
D=Z*77.1234567D0
L=D
RETURN
END
为了便于讨论,我们假设 D 等于 -1.5,在这种情况下 L 等于 -1 或 -2。 换句话说,是向上舍入还是向下舍入?
提前致谢。
最佳答案
使用内部函数 int
后,转换为整数类型进行赋值。效果定义为(F2008 13.7.81)
If A is of type real, there are two cases: if|A|<1, INT(A) has the value 0; if |A| ≥1, INT(A) is the integer whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as the sign of A.
在这种情况下,L
将采用值 -1
。
关于fortran - Fortran如何将实数转换为整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45884588/