Understanding Intrinsic 'Fraction' Function in Fortran

  • Context: Fortran 
  • Thread starter Thread starter PaulDirac
  • Start date Start date
  • Tags Tags
    Response Strange
Click For Summary
SUMMARY

The intrinsic 'fraction' function in Fortran, specifically in the GNU Fortran Compiler (gfortran), calculates the fractional part of a real number based on the specified base, which defaults to 2. In the example provided, fraction(10.0) returns 0.625 because it represents the fractional part of 10 in base 24, not the expected decimal representation. Understanding the base conversion is crucial for accurate usage of this function.

PREREQUISITES
  • Familiarity with Fortran programming language
  • Understanding of intrinsic functions in Fortran
  • Knowledge of number bases and conversions
  • Experience with the GNU Fortran Compiler (gfortran)
NEXT STEPS
  • Study the documentation for Fortran intrinsic functions
  • Learn about number base conversions and their implications in programming
  • Experiment with different inputs for the 'fraction' function in gfortran
  • Explore other intrinsic functions in Fortran for numerical analysis
USEFUL FOR

Fortran developers, numerical analysts, and anyone looking to understand intrinsic functions and numerical representations in Fortran.

PaulDirac
Messages
33
Reaction score
4
I have tried to use the intrinsic' fraction' function in Fortran but have failed to understand how it works. I thought that it would return the fractional part of a real number, but when I ran a few numbers through it, I got something that was a far cry from what I expected. For example, I tried fraction(10.0) and got 0.625. Can you tell me what's wrong?
 
Technology news on Phys.org

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 11 ·
Replies
11
Views
11K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K