This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Jan 2011 15:36:59 +0000
- Subject: [Bug fortran/47293] libquadmath: strtoflt128 - NAN not correctly read and C99 hex floating point format missing
- Auto-submitted: auto-generated
- References: <bug-47293-4@http.gcc.gnu.org/bugzilla/>
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;
}