DATA INF/1.D+300/ 在 Fortran 中意味着什么?
我正在将一些 Fortran 语言翻译成我们的 C# 应用程序,并试图弄清楚函数顶部的一些 Fortran 语言意味着什么。
DOUBLE PRECISION INF, DMIN, D12
DATA INF/1.D+300/
INF 的价值是多少?
I'm translating some Fortran to our C# app and I'm trying to figure out what a bit of Fortran means at the top of a function.
DOUBLE PRECISION INF, DMIN, D12
DATA INF/1.D+300/
What would the value of INF be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
D
表示“× 10< support>???",或者在 C# 中通常称为1.e+300
中的e
,但它用于双精度。DOUBLE PRECISION
语句< /a> 仅定义了 3 个double
类型的变量。DATA
语句翻译为
在 C# 中 。因此你会得到
由于
INF
太大了,我相信它意味着“无限”,在这种情况下,最好使用 真正的 IEEE 无穷大 (double INF = double.PositiveInfinity, ...
)。The
D
means "× 10???", or commonly known as thee
in1.e+300
in C#, but it's for double precision.The
DOUBLE PRECISION
statement just defines 3 variables to be of typedouble
.The
DATA
statementtranslates to
in C#. Hence you get
Since
INF
is so large I believe it means "Infinity", in that case it's better to use the real IEEE infinity (double INF = double.PositiveInfinity, ...
).该代码声明了一个名为
INF
(即无穷大)的常量,其值为 10^300。您可能需要替换double.PositiveInfinity
或double.MaxValue
。The code is declaring a constant called
INF
(i.e. infinity) with the value 10^300. You would want to substitutedouble.PositiveInfinity
ordouble.MaxValue
.代码采用 FORTRAN IV 或 FORTRAN 77 的风格,而不是 Fortran 90/95/2003。
双精度将变量声明为常规实数精度的两倍。我不确定那个时代的 FORTRAN 标准是否非常精确地表达了它的含义,因为当时有更多种类的数字硬件。如今,它实际上总是会获得 8 字节实数。 Data 语句初始化变量 INF。在常量“1.D+300”中使用“D”(而不是 E)是旧版 FORTRAN,用于指定该常量是双精度的。
Fortran(>=90)获得最大正双精度的方法是:
INF =巨大(1.0D+0)
The code is in the style of FORTRAN IV or FORTRAN 77 rather than Fortran 90/95/2003.
Double Precision declares the variables to be double the precision of a regular real. I'm not sure that the FORTRAN standards of that era were extremely precise about what that meant, since there was a greater variety of numeric hardware then. Today, it will virtually always obtain an 8-byte real. The Data statement initializes the variable INF. The use of "D" in the constant "1.D+300", instead of E, is old FORTRAN to specify that the constant is double precision.
The Fortran (>=90) way of obtaining the largest positive double is:
INF = huge (1.0D+0)
该值将为 1.0e300,但我确信其目的是将其设置为当前 CPU 上可以表示的最大双精度值。所以在 C# 中,这将是 double.PositiveInfinity,而不是某个硬编码值。
The value would be 1.0e300, but I'm sure that what is intended is that it be set to the largest double value that can be expressed on the current CPU. so in C# that would be
double.PositiveInfinity
rather than some hard-coded value.