public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tim Hollebeek <tim@hollebeek.com>
To: Paul Koning <pkoning@equallogic.com>
Cc: dewar@gnat.com, geoffk@geoffk.org, lars@nocrew.org, gcc@gcc.gnu.org
Subject: Re: Comparing doubles
Date: Sun, 07 Jul 2002 18:06:00 -0000	[thread overview]
Message-ID: <20020707161828.A13448@hollebeek.com> (raw)
In-Reply-To: <15656.15769.42000.732149@gargle.gargle.HOWL>

On Sun, Jul 07, 2002 at 09:09:45AM -0400, Paul Koning wrote:
> 
> As for compare, I don't claim to know the intricacies of IEEE NaN and
> all that, but surely on older float formats at least, compare is
> indeed internally just a subtract and test for zero?

The original suggestion, which seems to be missed by many, was
subtract _doubles_ and compare to _float_ zero.  Assuming that wasn't
an mistake, it is far, far different from standard equality (due to
the loss of precision from truncation).

Truncation before compare allows {a==b, b==c, c!=a}, and all other
sorts of unreasonable things.  Regardless of whether the standard
strictly requires it or not, it is reasonable to expect equality to be
an equivalence operation.

-Tim

  reply	other threads:[~2002-07-07 20:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-06 10:58 Robert Dewar
2002-07-07  9:09 ` Paul Koning
2002-07-07 18:06   ` Tim Hollebeek [this message]
2002-07-08  2:19     ` Lars Brinkhoff
  -- strict thread matches above, loose matches on Subject: below --
2002-07-07 21:37 Robert Dewar
2002-07-07 22:27 ` Tim Hollebeek
2002-07-07  9:20 Robert Dewar
2002-07-07  9:17 Robert Dewar
2002-07-08  3:10 ` Kai Henningsen
2002-07-06 10:28 Robert Dewar
2002-07-01 11:16 Lars Brinkhoff
2002-07-01 11:55 ` Geoff Keating
2002-07-01 23:24   ` Lars Brinkhoff
2002-07-02  7:48     ` Lars Brinkhoff
2002-07-01 12:13 ` Tim Hollebeek
2002-07-01 12:18 ` Alan Lehotsky

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=20020707161828.A13448@hollebeek.com \
    --to=tim@hollebeek.com \
    --cc=dewar@gnat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=geoffk@geoffk.org \
    --cc=lars@nocrew.org \
    --cc=pkoning@equallogic.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).