From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23336 invoked by alias); 4 Mar 2002 02:32:00 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Received: (qmail 23227 invoked from network); 4 Mar 2002 02:31:54 -0000 Received: from unknown (HELO uhura.concentric.net) (206.173.118.93) by sources.redhat.com with SMTP; 4 Mar 2002 02:31:54 -0000 Received: from cliff.concentric.net (cliff.concentric.net [206.173.118.90]) by uhura.concentric.net [Concentric SMTP Routing 1.0] id g242VqB03745 ; Sun, 3 Mar 2002 21:31:52 -0500 (EST) Errors-To: Received: from Clemens.cris.com (da003d0349.sjc-ca.osd.concentric.net [64.1.1.94]) by cliff.concentric.net (8.9.1a) id VAA09288; Sun, 3 Mar 2002 21:31:50 -0500 (EST) Message-Id: <5.1.0.14.2.20020303181544.02707180@pop3.cris.com> X-Sender: rrschulz@pop3.cris.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Sun, 03 Mar 2002 18:32:00 -0000 To: Ross Smith , "'Chuck Allison'" , cygwin@cygwin.com From: Randall R Schulz Subject: RE: Strange behavior In-Reply-To: <79218202D4B9D4118A290002A508E13B79C373@PNZEXCHANGE> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-SW-Source: 2002-03/txt/msg00150.txt.bz2 Ross, To call that result "pure luck" denies the fact that digital computers, when properly functioning, are 100% deterministic. Of course, it's not proper floating-point programming, but that doesn't mean "luck" is involved. Randall Schulz Mountain View, CA USA At 18:04 2002-03-03, Ross Smith wrote: > > From: Chuck Allison [mailto:cda@freshsources.com] > > > > I have a simple Rational number class and have discovered > > weird behavior > > with Cygwin's g++. If you look at the very short main program in file > > rtest2.cpp, you will see by the output that g++ get's the > > wrong answer for > > > > r1 / r2 == Rational(2,3); // should be true > > > > even though it prints as 2/3! Borland and Microsoft get it > > right. Any ideas? > > All code atached. > >[relevant bit of code] > >inline bool operator==(const Rational& r1, const Rational& r2) >{ > return r1.toDouble() == r2.toDouble(); >} > >This is nothing to do with Cygwin, or g++ for that matter. You're >comparing floating point numbers. Of course it's not reliable! If other >compilers happened to give you an exact equality on that particular >combination of arguments, it was pure luck. -- 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/