public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals
@ 2004-05-15  4:30 tobi at gcc dot gnu dot org
  2004-05-15  4:34 ` [Bug fortran/15441] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-05-15  4:30 UTC (permalink / raw)
  To: gcc-bugs

Quoting from http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00851.html:

The existing rrspacing code to handle denormals is broken. This occurs when x <
TINY(x), ie. expn == 0, frac != 0 I suspect the right shift should be a logical
(unsigned) shift, not an arithmetic (signed) one.

-- 
           Summary: [gfortran] RRSPACING broken for denormals
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,pbrook at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] [gfortran] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
@ 2004-05-15  4:34 ` pinskia at gcc dot gnu dot org
  2004-09-07  9:56 ` [Bug fortran/15441] " wf_cs at yahoo dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-15  4:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-14 17:32 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-14 17:32:55
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
  2004-05-15  4:34 ` [Bug fortran/15441] " pinskia at gcc dot gnu dot org
@ 2004-09-07  9:56 ` wf_cs at yahoo dot com
  2004-09-13 17:36 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: wf_cs at yahoo dot com @ 2004-09-07  9:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wf_cs at yahoo dot com  2004-09-07 09:56 -------
Hi, Tobi
  I think the code considered the denormal reals. Can you file a concrete test? 
In fact, the original code just didn't deal with zero. After applying your 
patch, I could not find another test to confirm this.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
  2004-05-15  4:34 ` [Bug fortran/15441] " pinskia at gcc dot gnu dot org
  2004-09-07  9:56 ` [Bug fortran/15441] " wf_cs at yahoo dot com
@ 2004-09-13 17:36 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
  2004-09-14 12:59 ` tobi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-09-13 17:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de  2004-09-13 17:36 -------
Subject: Re:  RRSPACING broken for denormals

wf_cs at yahoo dot com wrote:
> ------- Additional Comments From wf_cs at yahoo dot com  2004-09-07 09:56 -------
> Hi, Tobi
>   I think the code considered the denormal reals. Can you file a concrete test? 
> In fact, the original code just didn't deal with zero. After applying your 
> patch, I could not find another test to confirm this.
> 
I have to admit that I don't know a test. I added this because Paul said the
code wouldn't work for denormals, but didn't verify this myself. I will verify
this myself and will close the bug, if appropriate.

- Tobi


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-09-13 17:36 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
@ 2004-09-14 12:59 ` tobi at gcc dot gnu dot org
  2004-09-15  9:40 ` wf_cs at yahoo dot com
  2004-09-15 10:24 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-09-14 12:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-09-14 12:59 -------
I tried this:
x = 1.
i = 0
do while (x>0.)
   x = x/2.; i = i+1
   write(*,10) i, x, rrspacing(x)
10 format("2**(-",i3,") rrspacing(",e8.2,") =",e8.2)
end do
end
the output reads:
2**(-  1) rrspacing(0.50E+00) =0.84E+07
2**(-  2) rrspacing(0.25E+00) =0.84E+07
2**(-  3) rrspacing(0.13E+00) =0.84E+07
...
2**(-147) rrspacing(0.56E-44) =0.84E+07
2**(-148) rrspacing(0.28E-44) =0.84E+07
2**(-149) rrspacing(0.14E-44) =0.84E+07
2**(-150) rrspacing(0.00E+00) =0.00E+00

Now if I understand things correctly and got my facts right, the relative
spacing should become larger once we hit denormals, because we don't have as
many digits left for recording the mantissa. More precisely, IIRC numbers with
exponent in [-149,-126] are denormals, and their relative spacing should
increase by a factor of two at every iteration of the above program, for
RRSPACING to be also meaningful in the case of denormals.

I understand that denormals are not part of the floating point model specified
in the standard, and therefore the behavior of RRSPACING is not specified for
denormals, therefore I'm changing the severity to 'enhancement', but I'm not
convinced that we're doing The Right Thing.

BTW the program compiled with ifc gives the same output as with gfortran.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-09-14 12:59 ` tobi at gcc dot gnu dot org
@ 2004-09-15  9:40 ` wf_cs at yahoo dot com
  2004-09-15 10:24 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: wf_cs at yahoo dot com @ 2004-09-15  9:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wf_cs at yahoo dot com  2004-09-15 09:40 -------
I understand this problem this way. In fortran standard, 

RRSPACING (X) = |X * POW (2, -e)| * POW (2, p) = FRACTION (X) * POW (2, p)
 
So the result's exponenet is p. And if X is normalized, X's fraction part
is the result's fraction. If X is denormalized, to get the X's fraction we
shift X's fraction part to left until the first '1' is removed.

That's why if X's fraction has only '1', we will get the same result as you 
test.

I agree that the behavior of RRSPACING is not specified for denormals. But I 
think we do the Right Thing as I explained.
I attach a pathch to give more comments about the code and add some folding. 
How do you think?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/15441] RRSPACING broken for denormals
  2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-09-15  9:40 ` wf_cs at yahoo dot com
@ 2004-09-15 10:24 ` tobi at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tobi at gcc dot gnu dot org @ 2004-09-15 10:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tobi at gcc dot gnu dot org  2004-09-15 10:24 -------
I looked at the standard again, and it says ""[RRSPACING] Returns the reciprocal
of the relative spacing of model numbers near the argument". I.e., it is not
only specified for model numbers (as I wrongly assumed), but for a denormal it
should return the spacing of a nearby normalized number, and so indeed, you're
right (we could also return RRSPACING(0), and agree with the standard, but I
don't think that's what people would expect).

> I attach a pathch to give more comments about the code and add some folding. 
> How do you think?
> 

Post it to the mailing list, and let the maintainers decide :-)

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15441


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-09-15 10:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-15  4:30 [Bug fortran/15441] New: [gfortran] RRSPACING broken for denormals tobi at gcc dot gnu dot org
2004-05-15  4:34 ` [Bug fortran/15441] " pinskia at gcc dot gnu dot org
2004-09-07  9:56 ` [Bug fortran/15441] " wf_cs at yahoo dot com
2004-09-13 17:36 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-09-14 12:59 ` tobi at gcc dot gnu dot org
2004-09-15  9:40 ` wf_cs at yahoo dot com
2004-09-15 10:24 ` tobi at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).