Help needed in floating point calc in fortran

In summary, the speaker needs help in determining the "Single-Precision Machine Constants" for their desktop computer. They are encountering a problem and are asking for assistance in determining R1MACH(1 to 5). The code for these constants is provided and references to a framework for a portable library are also mentioned.
  • #1
cslam
1
0
Help!
I know almost nothing about Fortran but need to use a program by others. I encountered a problem in determining the "Single-Precision Machine Constants" for my desktop computer (intel pentium dual core 5200 2mb l2 2.5ghz 800 fsb with Window Vista). Please take a look at following part or comment in the code. Could anyone help me to determne R1MACH(1 to 5)?

C Single-Precision Machine Constants r1mach27
C R1MACH(1) = B**(EMIN-1), the smallest positive magnitude. r1mach28
C R1MACH(2) = B**EMAX*(1 - B**(-T)), the largest magnitude. r1mach29
C R1MACH(3) = B**(-T), the smallest relative spacing. r1mach30
C R1MACH(4) = B**(1-T), the largest relative spacing. r1mach31
C R1MACH(5) = LOG10(B) r1mach32
C***REFERENCES FOX, P.A., HALL, A.D., SCHRYER, N.L, *FRAMEWORK FOR r1mach33
C A PORTABLE LIBRARY*, ACM TRANSACTIONS ON MATHE- r1mach34
C MATICAL SOFTWARE, VOL. 4, NO. 2, JUNE 1978, r1mach35
C PP. 177-188. r1mach36
 
Technology news on Phys.org
  • #3


As a scientist, my first recommendation would be to consult with someone who is familiar with Fortran and programming in general. It can be challenging to troubleshoot code without prior knowledge and experience in a specific programming language. In addition, it may be helpful to refer to the references listed in the code for further guidance.

However, based on the information provided, it seems like the code is trying to calculate some machine constants for single-precision floating point numbers. These constants are important for understanding the precision and range of numbers that can be represented in a specific computer system.

To determine R1MACH(1 to 5), you would need to know the base (B) and the exponent range (EMIN and EMAX) of the floating point representation in Fortran. These values may vary depending on the compiler and system being used. You can try looking for documentation or online resources that provide this information for your specific system.

Alternatively, you can also try experimenting with different values for B, EMIN, and EMAX to see how they affect the results. This can give you a better understanding of how these constants are calculated and their significance in your program.

Overall, my main advice would be to seek help from someone familiar with Fortran and to do some further research on the specific machine constants you are trying to determine. Good luck!
 

1. What is floating point calculation in Fortran?

Floating point calculation in Fortran refers to the process of performing mathematical operations on numbers that have a decimal point. These numbers are represented in a binary format and are subject to certain limitations due to the finite precision of the computer's hardware.

2. Why is help needed in floating point calculation in Fortran?

Help may be needed in floating point calculation in Fortran because it can be a complex and error-prone process. Fortran has specific rules and limitations for floating point calculations, and understanding them can be challenging for beginners. Additionally, certain types of calculations, such as those involving very large or very small numbers, can lead to unexpected results if not handled properly.

3. How can I improve my floating point calculation in Fortran?

To improve your floating point calculation in Fortran, you can follow certain best practices. These include using the appropriate data types for your calculations, avoiding unnecessary conversions between data types, and being aware of the limitations of floating point numbers. You should also test your code thoroughly and use debugging tools to identify and fix any errors.

4. What are the common pitfalls of floating point calculation in Fortran?

Some common pitfalls of floating point calculation in Fortran include rounding errors, loss of precision, and overflow or underflow of numbers. These can occur due to the finite precision of floating point numbers and the way they are stored and manipulated in the computer's memory. It is important to be aware of these pitfalls and to handle them appropriately in your code.

5. Are there any alternatives to floating point calculation in Fortran?

Yes, there are alternative methods for performing calculations with decimal numbers in Fortran. One option is to use the decimal data type, which allows for more precise calculations but may be slower and less efficient. Another option is to use a different programming language that may have better support for decimal calculations, such as Python or Java.

Similar threads

  • Computing and Technology
Replies
4
Views
758
  • Engineering and Comp Sci Homework Help
Replies
10
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
5K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top