public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing
@ 2011-01-14 15:37 burnus at gcc dot gnu.org
  2011-01-14 15:43 ` [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and " burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-14 15:37 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: libquadmath: strtoflt128 - C99 hex floating point
                    format missing
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


(At some point, I - or someone else - should really create a libquadmath
component in Bugzilla.)

Follow up to http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00369.html

strtoflt128 currently does not support the C99 hex floating point format

However, there is: "gethex" in gdtoa/strtodg.c (called from strtoflt128) thus
it might already be implemented.

>From POSIX 2003 for strtod:

"The expected form of the subject sequence is an optional plus or minus sign,
 then one of the following:
 [...]
 * A 0x or 0X, then a non-empty sequence of hexadecimal digits optionally
   containing a radix character, then an optional binary exponent part"


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
@ 2011-01-14 15:43 ` burnus at gcc dot gnu.org
  2011-01-22 16:05 ` jvdelisle at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-14 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|libquadmath: strtoflt128 -  |libquadmath: strtoflt128 -
                   |C99 hex floating point      |NAN not correctly read and
                   |format missing              |C99 hex floating point
                   |                            |format missing

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-14 15:36:52 UTC ---
Additional problem: The NAN string to float128 conversion does not seem to
work.

[The way NaN is printed by the float128->string conversion function is also a
bit odd, but it seems to work (with libgfortran).]

The program below prints:

+N.aN000000000000000000e+02
+7.82797652694030368547e-4942

The a similar Fortran program prints (value printed as hex):
     0        0        0 FFFF8000   -- for NaN (gfortran and ifort)
     0 C0000000     FFFF        0   -- for the "NaN" string (= 0.78280E-4941)

If one debugs gdtoa/strtodg.c, one sees that STRTOG_NaN is properly detected.
Thus, either the bits are wrong in strtodg -- or it is wrongly handled in
strtoflt128.

Example (strtoflt128 was called "quadmath_strtopQ" before renaming.)

#include <quadmath.h>
#include <stdlib.h>  /* For abort.  */
#include <stdio.h>   /* For printf.  */

int main ()
{
  __float128 r;
  char str[200];
  r = nanq(NULL);
  quadmath_dtoaq (str, sizeof (str), 20, r);
  printf("%s\n", str);

  r = 3.0q;
  /* quadmath_strtopQ ("NaN", NULL, &r); */
  r = strtoflt128 ("NaN", NULL);
  quadmath_dtoaq (str, sizeof (str), 20, r);
  printf("%s\n", str);

  if (!isnanq(r)) abort();
  return 0;
}


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
  2011-01-14 15:43 ` [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and " burnus at gcc dot gnu.org
@ 2011-01-22 16:05 ` jvdelisle at gcc dot gnu.org
  2011-01-26  6:09 ` jvdelisle at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-01-22 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot
                   |                            |gnu.org
         AssignedTo|unassigned at gcc dot       |jvdelisle at gcc dot
                   |gnu.org                     |gnu.org

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-01-22 14:25:52 UTC ---
Taking this one


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
  2011-01-14 15:43 ` [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and " burnus at gcc dot gnu.org
  2011-01-22 16:05 ` jvdelisle at gcc dot gnu.org
@ 2011-01-26  6:09 ` jvdelisle at gcc dot gnu.org
  2011-02-01  2:29 ` jvdelisle at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-01-26  6:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-01-26 05:45:35 UTC ---
I think this fixes it.  Why it was whacked, who knows.

Index: gd_qnan.h
===================================================================
--- gd_qnan.h    (revision 169141)
+++ gd_qnan.h    (working copy)
@@ -2,9 +2,9 @@
 #define d_QNAN0 0x0
 #define d_QNAN1 0xfff80000
 #define ld_QNAN0 0x0
-#define ld_QNAN1 0xc0000000
-#define ld_QNAN2 0xffff
-#define ld_QNAN3 0x0
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0xffff8000
 #define ldus_QNAN0 0x0
 #define ldus_QNAN1 0x0
 #define ldus_QNAN2 0x0


Test program I used. Try this without the patch and it is very obvious what is
wrong.

character(len=200) :: str
real(16) :: r, x, y, z
integer(16) :: k
x = 0.0
y = 0.0
r = 1.0
str = 'NAN' ; read(str,*) r
print *, r
z = x/y
print *, z
k = transfer(z,k)
print "(b128)", k
print *
k = transfer(r,k)
print "(b128)", k
end


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-01-26  6:09 ` jvdelisle at gcc dot gnu.org
@ 2011-02-01  2:29 ` jvdelisle at gcc dot gnu.org
  2011-02-02 18:29 ` dnovillo at gcc dot gnu.org
  2011-02-06 22:13 ` jvdelisle at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-01  2:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-01 02:29:21 UTC ---
Author: jvdelisle
Date: Tue Feb  1 02:29:18 2011
New Revision: 169466

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169466
Log:
2011-01-31  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR libquadmath/47293
    * gdtoa/qd_qnan.h: Fix NAN bit patterns.
    * gdtoa/strtopQ.c (strtoflt128): Handle endianess with NAN.

Modified:
    trunk/libquadmath/ChangeLog
    trunk/libquadmath/gdtoa/gd_qnan.h
    trunk/libquadmath/gdtoa/strtopQ.c


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-02-01  2:29 ` jvdelisle at gcc dot gnu.org
@ 2011-02-02 18:29 ` dnovillo at gcc dot gnu.org
  2011-02-06 22:13 ` jvdelisle at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 18:14:27 UTC ---
Author: dnovillo
Date: Wed Feb  2 18:14:22 2011
New Revision: 169738

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169738
Log:
2011-01-31  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR libquadmath/47293
    * gdtoa/qd_qnan.h: Fix NAN bit patterns.
    * gdtoa/strtopQ.c (strtoflt128): Handle endianess with NAN.

Modified:
    branches/google/integration/libquadmath/ChangeLog
    branches/google/integration/libquadmath/gdtoa/gd_qnan.h
    branches/google/integration/libquadmath/gdtoa/strtopQ.c


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

* [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
  2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-02-02 18:29 ` dnovillo at gcc dot gnu.org
@ 2011-02-06 22:13 ` jvdelisle at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-06 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-06 22:07:16 UTC ---
Fixed on trunk and google.  Google?  ;)


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

end of thread, other threads:[~2011-02-06 22:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-14 15:37 [Bug fortran/47293] New: libquadmath: strtoflt128 - C99 hex floating point format missing burnus at gcc dot gnu.org
2011-01-14 15:43 ` [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and " burnus at gcc dot gnu.org
2011-01-22 16:05 ` jvdelisle at gcc dot gnu.org
2011-01-26  6:09 ` jvdelisle at gcc dot gnu.org
2011-02-01  2:29 ` jvdelisle at gcc dot gnu.org
2011-02-02 18:29 ` dnovillo at gcc dot gnu.org
2011-02-06 22:13 ` jvdelisle at gcc dot gnu.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).