delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/03/10:27:27

Date: Sun, 3 May 1998 17:25:49 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Eric Rudd <rudd AT cyberoptics DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Library Function qsort() Exhibits N^2 Behavior
In-Reply-To: <35477151.99373E76@cyberoptics.com>
Message-ID: <Pine.SUN.3.91.980503172529.19706D-100000@is>
MIME-Version: 1.0

On Wed, 29 Apr 1998, Eric Rudd wrote:

> As far as the DJGPP implementation of qsort is concerned, I am actually
> more worried about a problem I discovered a while ago, when I attempted
> to use qsort to do a sort based on floating-point values. Due to the
> optimizer storing one comparison value in memory, and leaving the other
> in the coprocessor stack to higher precision, the results of the
> comparison were sometimes inconsistent for equal or nearly-equal
> comparison values.

Comparing close FP values can be tricky.  Maybe if you post the
comparison function, somebody could suggest ways of making it more
stable.

There's also the -ffloat-store option to GCC which might be helpful in
such situations.

- Raw text -


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