public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vincent-srcware at vinc17 dot net" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug manual/31322] New: Section 9.1 should document that the comparison function used in the example is not transitive Date: Wed, 31 Jan 2024 15:15:27 +0000 [thread overview] Message-ID: <bug-31322-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=31322 Bug ID: 31322 Summary: Section 9.1 should document that the comparison function used in the example is not transitive Product: glibc Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: manual Assignee: unassigned at sourceware dot org Reporter: vincent-srcware at vinc17 dot net CC: mtk.manpages at gmail dot com Target Milestone: --- Section 9.1 gives an example of a comparison function on floating-point numbers of type "double" that is not transitive due to possible NaN values. This can be shown by the following program: #include <stdio.h> #include <math.h> int compare_doubles (const void *a, const void *b) { const double *da = (const double *) a; const double *db = (const double *) b; return (*da > *db) - (*da < *db); } int main (void) { double t[3] = { 1.0, NAN, 2.0 }; printf ("%d\n", compare_doubles(t+0, t+1)); printf ("%d\n", compare_doubles(t+1, t+2)); printf ("%d\n", compare_doubles(t+0, t+2)); return 0; } which gives 0 0 -1 while the initial 0 0 implies a third 0 with a transitive comparison function. This should be documented. Apparently, this is not clear to everyone: https://sourceware.org/pipermail/libc-alpha/2024-January/154350.html -- You are receiving this mail because: You are on the CC list for the bug.
reply other threads:[~2024-01-31 15:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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-31322-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: linkBe 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).