delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/02/16/02:25:53

X-Spam-Check-By: sourceware.org
Date: Fri, 16 Feb 2007 08:25:24 +0100
From: Peter Rosin <peda AT lysator DOT liu DOT se>
To: cygwin AT cygwin DOT com
Subject: Re: strange bug in gettimeofday function
Message-ID: <20070216072523.GC5996@arnhem.lysator.liu.se>
References: <13811889795 DOT 20070215071733 AT gnu DOT org> <er2v5b$nmj$1 AT sea DOT gmane DOT org> <106982500 DOT 20070216041231 AT gnu DOT org>
Mime-Version: 1.0
In-Reply-To: <106982500.20070216041231@gnu.org>
User-Agent: Mutt/1.4.1i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Fri, Feb 16, 2007 at 04:12:31AM +0300, Andrew Makhorin wrote:
> > I would be suspicious of floating-point rounding errors here for the
> > original problem you described.  Why don't you try a test case that just 
> > checks if one tv is ever less than a previous tv, without the conversions.
> 
> Because I could not reproduce the bug concerning gettimeofday out of
> a complex program where it is used. Probably it works correctly. But
> then I would like to know why comparison of two floating-point numbers
> leads to different results: t0 is *exactly* the same as t1, nevertheless
> the condition t0 > t1 is true (sometimes). That is the question.

It could be that t0 has been stored in memory and in that process it
is rounded up, while t1 has been kept in an FPU register from the first
time it was calculated, and has thus retained a higher precision.

When you compile without optimization, the t1 value might also take
a roundtrip to memory, and is in that process subject to the same
rounding as the t0 value.

/me is out on a limb

Cheers,
Peter

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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