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,967 of 5,127    |
|    Gary Scott to Steven G. Kargl    |
|    Re: FRACTION() seems broken in gfortran     |
|    16 Aug 25 20:40:13    |
   
   From: garylscott@sbcglobal.net   
      
   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:   
      
   "The fractional part of a real number is the decimal portion of the   
   number, excluding the integer part. It represents the difference between   
   the real number and its integer part. This is often denoted by curly   
   braces {x} or frac(x).   
   In more detail:   
   Real Number Representation:   
   Every real number can be expressed as the sum of an integer and a   
   fractional part. For example, 3.14 can be written as 3 + 0.14, where 3   
   is the integer part and 0.14 is the fractional part.   
   Fractional Part Function:   
   The fractional part function, denoted by {x}, is defined as the   
   difference between the real number x and its integer part.   
   Formula:   
   {x} = x - ⌊x⌋, where ⌊x⌋ is the floor function (the greatest integer   
   less than or equal to x).   
   Example:   
   If x = 3.14, then {x} = 3.14 - ⌊3.14⌋ = 3.14 - 3 = 0.14.   
   Range:   
   The fractional part of a number is always between 0 and 1 (inclusive of   
   0, exclusive of 1). For integers, the fractional part is 0. "   
      
   So, they would expect fraction(3.0) to be 0, not 0.75.   
      
   --- 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