问题描述
在逻辑,并在*啊哈*的正确设计的的编程语言,一个布尔值比较真实永远是多余的,即 A ==真
应该通过简单的替换一个
。 (同样, A ==假
按不是
)。
In logic, and in *ahem* properly designed programming languages, comparing a boolean to true is always redundant, i.e. a == True
should be replaced by simply a
. (And similarly, a == False
by not a
).
许多语言,包括C,没有一个正确的布尔类型所以它的可以的有所作为,你是否具有真正的(如 2比较真实==
收益率 0
,这是一个布尔值重新presents假的,而 2
本身可以重新present真)。
Many languages, including C, don't have a proper boolean type so it can make a difference whether you compare with true (e.g. 2 == true
yields 0
, which as a boolean represents false, while 2
itself can represent true).
这也是在Fortran语言的问题,我也可以随时更换 A .eqv。 .TRUE。
按 A
?
Is this also an issue in Fortran, or can I always replace a .eqv. .true.
by a
?
(我发现,在一些传统code和大量我怀疑这只是的很多事情,笔者真的没有想到过......但我很好奇是否有竟有些特殊情况隐藏1还有,我应该注意。)
(I found that in some legacy code, and I heavily suspect it's just one of the many things that the authors didn't really think through... but I'm curious whether there's actually some special case hidden there I should watch out for.)
推荐答案
没有,也没有理由去写。 A .eqv。 .TRUE。
相同 A
。只要不使用 ==
,是用于不同的数据类型。
No, there is no reason to write that. a .eqv. .true.
is the same as a
. Just don't use ==
, that is used for different data types.
对于在传统codeS发现的东西,不要忘记,许多,如果不是大多数,Fortran语言的用户不是专业的程序员和从未接受过适当的编程技术的全面培训。通常情况下,他们只是教语言规则。
Regarding things found in legacy codes, don't forget that many, if not most, Fortran users are not professional programmers and never received thorough training in proper programming techniques. Often, they were just taught the language rules.
这篇关于是否有过一个理由来写.eqv。 。真正。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!