delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/04/00:42:31

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Originating-IP: [129.78.64.5]
From: "Gareth Pearce" <tilps AT hotmail DOT com>
To: cygwin AT cygwin DOT com
Subject: RE: Strange behavior
Date: Mon, 04 Mar 2002 05:42:01
Mime-Version: 1.0
Message-ID: <F46E3IvhXJ4dErcD9YN00018063@hotmail.com>
X-OriginalArrivalTime: 04 Mar 2002 05:42:02.0437 (UTC) FILETIME=[4F545F50:01C1C33F]

>Floating point comparisons should _always_ be done via a confidence
>interval, not bitwise equality. As for determinism, I don't know what
>the logic circuits look like, so can't and won't comment :}.
>
>Rob

confidence intervals are indeed the only way...

but as to determinism ... its a function of your compiler I believe.  
Differences will likely arrise with or without optimisation.
Which coincidently - is also the difference between the 2 situations below, 
1 is an optimisation of the other, the assembly produced, even without an 
optimisation flag, will be different, which means different results (one 
case needs temporary variables - other one does not).  So it should be 
deterministic for a single set of assembly, for a given system type... 
although someone could easily of made a processor in which I am wrong.

Gareth
>
>
>
> > -----Original Message-----
> > From: Chuck Allison [mailto:cda AT freshsources DOT com]
> > Sent: Monday, March 04, 2002 4:08 PM
> > To: Richard R. Malloy; Randall R Schulz
> > Cc: Ross Smith; cygwin AT cygwin DOT com
> > Subject: Re: Strange behavior
> >
> >
> > That's the point. They're always redued, so in both cases,
> > the expression 2.0/3.0 is evaluated. How can that be
> > non-deterministic?
> >
> > ----- Original Message -----
> > From: "Richard R. Malloy" <rrmalloy AT attbi DOT com>
> > To: "Randall R Schulz" <rrschulz AT cris DOT com>
> > Cc: "Ross Smith" <rosss AT pharos DOT co DOT nz>; "'Chuck Allison'"
> > <cda AT freshsources DOT com>; <cygwin AT cygwin DOT com>
> > Sent: Sunday, March 03, 2002 9:47 PM
> > Subject: Re: Strange behavior
> >
> >
> > > OK. I'm no IA32 expert can someone explain the following
> > results.  (Do
> > > the floating point registers use guard bits, randomly initialized
> > > perhaps?)
> > >
> > > bool operator==(const Rational& r1, const Rational& r2)
> > > {
> > >   double a=r1.toDouble(), b=r2.toDouble();
> > >   cout << ?== a " << a << " " << ?== b " << b << endl;
> > >   return a == b;
> > >   //  return r1.toDouble() == r2.toDouble();
> > >   /*  return ( r1.numerator == r2.numerator && r1.denominator ==
> > > r2.denominator ); */ }
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting:         http://cygwin.com/bugs.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/
>




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019