This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strange bug in gettimeofday function


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]