Fortran77: What does a period in the middle of an eq mean?

  • Context: Fortran 
  • Thread starter Thread starter dimensionless
  • Start date Start date
  • Tags Tags
    Fortran77 Mean Period
Click For Summary

Discussion Overview

The discussion revolves around the interpretation of a period in Fortran 77 code, specifically in the context of numerical types and their implications for variable assignments. Participants explore the significance of using a period to denote floating-point numbers versus integers within the programming language.

Discussion Character

  • Technical explanation, Conceptual clarification, Debate/contested

Main Points Raised

  • One participant questions the meaning of the period in the expression "R(1)=2.*RL(1)*N(1)" in Fortran 77 code.
  • Another participant suggests that the period indicates to the compiler that "2" is a float variable rather than an integer, which could affect the program's behavior.
  • A third participant references external documentation that describes the period as a radix point and a delimiter for various constants and operators in Fortran.
  • One participant asserts that "2" is treated as an integer while "2." is treated as a float, and provides an alternative way to express the float using the function float(2).
  • A follow-up question is raised about when the period is necessary in expressions.
  • Another participant explains that using "2." or float(2) is required to ensure that R(1) is treated as a float, noting that some modern compilers may handle this differently but emphasizes the importance of good programming practice.

Areas of Agreement / Disagreement

Participants express varying interpretations of the necessity and implications of using a period in Fortran 77 code. There is no consensus on a definitive answer, and multiple viewpoints regarding best practices and compiler behavior are presented.

Contextual Notes

Some participants mention that modern compilers may overlook the need for a period, indicating a potential dependency on compiler behavior and version. The discussion does not resolve the nuances of when the period should be used.

Who May Find This Useful

Individuals interested in legacy programming languages, specifically Fortran 77, and those looking to understand numerical type handling in programming may find this discussion relevant.

dimensionless
Messages
461
Reaction score
1
I'm trying to comprehend some old Fortran 77 code. I've run across an a line of code that resembles the following:
Code:
R(1)=2.*RL(1)*N(1)
What does the period in the above code mean?
 
Technology news on Phys.org
I'm no Fortran expert, but I'll make an educated guess:
I suspect the period is there simply to indicate to the compiler that the "2" is a float variable rather than an integer. Without the period, the compiler might treat the "2" as an integer, which could cause problems elsewhere in the program.
 
http://www.ictp.trieste.it/~manuals/programming/sun/fortran/f77rm/1_elements.doc.html has list of fortran symbols. According to them the period(.) is a Radix point, delimiter for logical constants and operators, record fields.
 
Last edited by a moderator:
DuncanM has it corretct, 2 is an integer, 2. a float. Also can be written as

R(1)=float(2)*RL(1)*N(1)
 
When does the period need to be used?
 
If you want R(1) to be a float, you have to use either 2. or float(2) in the expression, if not R(2) probably will be truncated to an integer value. Many of the more recent compilers will overlook this and convert it to a float variable, it is just good programming practice to have it in there or else you may have problems down the road.
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K