Understanding Intrinsic 'Fraction' Function in Fortran

  • Thread starter Thread starter PaulDirac
  • Start date Start date
  • Tags Tags
    Response Strange
AI Thread Summary
The intrinsic 'fraction' function in Fortran is designed to return the fractional part of a real number, but its output can be misleading if not understood correctly. The confusion arises from the fact that the function does not simply return the decimal fraction of a number. Instead, it computes the fractional part based on the underlying representation of the number in floating-point format. For instance, when inputting 10.0, the output of 0.625 reflects the fractional part when 10 is expressed in a different base, specifically base 24, as shown in the equation 10 = 0.625 * 24. Understanding the function's behavior in relation to floating-point representation is crucial for accurate usage.
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
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Replies
8
Views
2K
Replies
8
Views
4K
Replies
6
Views
3K
Replies
11
Views
11K
Replies
3
Views
3K
Replies
9
Views
2K
Back
Top