public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: FX <fxcoudert@gmail.com>
Cc: fortran@gcc.gnu.org
Subject: Re: New signaling NaN causes 12 testsuite failures
Date: Tue, 25 Jan 2022 11:59:28 -0800	[thread overview]
Message-ID: <20220125195928.GB69322@troutmask.apl.washington.edu> (raw)
In-Reply-To: <93B4F458-9AD2-44DA-9F21-37B16C4A0CE8@gmail.com>

On Tue, Jan 25, 2022 at 09:05:55AM +0100, FX wrote:
> 
> > Got the following in testsuite/gfortran/gfortran.log
> > 
> > NaN 7FFFA000000000000000
> > NaN 7FFFC000000000000000
> > NaN 7FFFA000000000000000
> > 

Could be a problem with __builtin_nansl().

#include <stdio.h>
#include <stdint.h>

int
main(void)
{
   union {       float x; uint32_t i; }    f;
   union {      double x; uint64_t i; }    d;
   union { long double x; uint64_t i[2]; } l;

   printf("Quiet NaN\n");
   f.x = __builtin_nanf("");
   printf("%f %x\n", f.x, f.i);
   d.x = __builtin_nan("");
   printf("%lf %lx\n", d.x, d.i);
   l.x = __builtin_nanl("");
   printf("%Lf %lx%lx\n", l.x, l.i[1], l.i[0]);

   printf("Signaling NaN\n");
   f.x = __builtin_nansf("");
   printf("%f %x\n", f.x, f.i);
   d.x = __builtin_nans("");
   printf("%lf %lx\n", d.x, d.i);
   l.x = __builtin_nansl("");
   printf("%Lf %lx%lx\n", l.x, l.i[1], l.i[0]);

   return 0;
} 

% ~/work/x/bin/gcc -o z a.c && ./z
Quiet NaN
nan 7fc00000
nan 7ff8000000000000
nan 7fffc000000000000000
Signaling NaN
nan 7fa00000
nan 7ff4000000000000
nan 7fffa000000000000000

s bit is 0, so the 7 is correct.  The width of the 
exponet is w = 8, 11, and 15 bits for float, double,
and long double.  The first significant bit, d, is
then 9, 12, and 16.
         s|----w---|d
7fc  --> 0111 1111 1100
7fa  --> 0111 1111 1010
         s|-----w-----| d
7ff8 --> 0111 1111 1111 1000
7ff4 --> 0111 1111 1111 0100
         s|-------w--------| d
7fffc -> 0111 1111 1111 1111 1100 <-- should be 7fff8?
7fffa -> 0111 1111 1111 1111 1010 <-- should be 7fff4?

What does linux/darwin show?

-- 
Steve

  parent reply	other threads:[~2022-01-25 19:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  0:44 Steve Kargl
2022-01-25  2:48 ` Steve Kargl
2022-01-25  8:05   ` FX
2022-01-25 17:42     ` Steve Kargl
2022-01-25 19:59     ` Steve Kargl [this message]
2022-01-25 20:04       ` FX
2022-01-25 20:20         ` Steve Kargl
2022-01-25  8:09 ` FX
2022-01-25 16:52   ` Steve Kargl
2022-01-25 19:35   ` Steve Kargl
2022-01-25 19:52     ` FX
2022-01-25 20:12       ` Steve Kargl
2022-01-25 20:45       ` Steve Kargl
2022-01-25 20:56         ` FX
2022-01-25 21:05           ` Steve Kargl
2022-01-25 23:11             ` FX
2022-01-26 10:47           ` Tobias Burnus
2022-01-26 16:02             ` Steve Kargl
2022-01-26 16:19               ` FX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220125195928.GB69322@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=fxcoudert@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).