The arithmetic IF statement is a three-way arithmetic
conditional statement, first seen in the first release of
Fortran in 1957, and found in all later versions, and some other programming languages, such as
FOCAL. Unlike the
logical IF statements seen in other languages, the Fortran statement defines three different branches depending on whether the result of an expression is negative, zero, or positive, in said order, written as:
IF (expression) negative,zero,positive
Deprecation
While it originally was the only kind of IF statement provided in Fortran, the feature has been used less and less frequently after the
logical IF statements were introduced, and was finally labeled
obsolescent
Obsolescence is the state of being which occurs when an object, service, or practice is no longer maintained or required even though it may still be in good working order. It usually happens when something that is more efficient or less risky r ...
in Fortran 90. As of Fortran 2018, it is no longer required for compilers to implement arithmetic IF and it is considered to be a deleted feature. The GNU Fortran compiler has been producing warnings for arithmetic IF by default since its 9.1 release in 2019.
See also
*
Sign function
In mathematics, the sign function or signum function (from '' signum'', Latin for "sign") is an odd mathematical function that extracts the sign of a real number. In mathematical expressions the sign function is often represented as . To avoi ...
*
Three-way comparison
In computer science, a three-way comparison takes two values A and B belonging to a type with a total order and determines whether A < B, A = B, or A > B in a single operation, in accordance with the mathematical law of trichotomy.
Machine- ...
Notes
References
arithmetic IF @ everything2.com
Conditional constructs
Fortran
{{computer-science-stub