Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.fortran    |    Putting John Backus on a giant pedestal    |    5,127 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,968 of 5,127    |
|    Steven G. Kargl to Gary Scott    |
|    Re: FRACTION() seems broken in gfortran     |
|    17 Aug 25 03:18:03    |
      From: sgk@REMOVEtroutmask.apl.washington.edu              On Sat, 16 Aug 2025 20:40:13 -0500, Gary Scott wrote:              > On 8/16/2025 7:02 PM, Steven G. Kargl wrote:       >> On Fri, 15 Aug 2025 22:24:52 +0000, Lawrence D’Oliveiro wrote:       >>       >>> On Thu, 14 Aug 2025 11:21:00 +0800, Woozy Song wrote:       >>>       >>>> A program was going wrong, and found       >>>> FRACTION(3.75)=0.9375 and FRACTION(2.5)=0.9375       >>>       >>> Broken as designed, according to the spec.       >>>       >>> Why on Earth does FRACTION have this meaning?       >>       >> To what spec are you referring?       >>       >> gfortran is giving the correct answer (although       >> I suspect OP has a transcription problem with       >> the second example).       >>       >       > I think most casual, non-math, non-floating point experts would expect this:              For someone programming in the Fortran language, I would expect       that they would consult some form of documentation to learn why       their expectation might be wrong. For example, the gfortran       documentation (which comes with the compiler) contains                     8.119 ‘FRACTION’ -- Fractional part of the model representation       ===============================================================              _Synopsis_:        ‘Y = FRACTION(X)’              _Description_:        ‘FRACTION(X)’ returns the fractional part of the model        representation of ‘X’.              _Class_:        Elemental function              _Arguments_:        X The type of the argument shall be a ‘REAL’.              _Return value_:        The return value is of the same type and kind as the argument. The        fractional part of the model representation of ‘X’ is returned; it        is ‘X * RADIX(X)**(-EXPONENT(X))’.              _Example_:        program test_fraction        real :: x        x = 178.1387e-4        print *, fraction(x), x * radix(x)**(-exponent(x))        end program test_fraction              --       steve              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca