public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nszabolcs at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug math/18238] New: quality of implementation: fmin and fmax should handle signed zeros
Date: Fri, 10 Apr 2015 11:03:00 -0000	[thread overview]
Message-ID: <bug-18238-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=18238

            Bug ID: 18238
           Summary: quality of implementation: fmin and fmax should handle
                    signed zeros
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: nszabolcs at gmail dot com

ISO C with Annex F seems to allow the result of fmax and fmin to have arbitrary
sign when the arguments are zeros, but ideally the sign should be handled
because these functions are supposed to have exact result.

http://port70.net/~nsz/c/c11/n1570.html#F.10.9.2

the code below outputs:

fmax(0, -0.0) signbit is not 0
fmaxf(0, -0.0f) signbit is not 0
fmaxl(-0.0L, 0) signbit is not 0
fmin(-0.0, 0) signbit is not 1
fminf(-0.0f, 0) signbit is not 1
fminl(0, -0.0L) signbit is not 1


#include <math.h>
#include <stdio.h>

#define T(f,s) if (signbit(f) != s) printf(#f " signbit is not " #s "\n");

int main()
{
T(fmax(0, -0.0), 0)
T(fmaxf(0, -0.0f), 0)
T(fmaxl(-0.0L, 0), 0)
T(fmin(-0.0, 0), 1)
T(fminf(-0.0f, 0), 1)
T(fminl(0, -0.0L), 1)
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2015-04-10 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10 11:03 nszabolcs at gmail dot com [this message]
2015-04-10 16:32 ` [Bug math/18238] " jsm28 at gcc dot gnu.org

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=bug-18238-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).