On Thu, 4 Dec 2014, Sven Schreiber wrote:
Am 04.12.2014 um 18:59 schrieb Allin Cottrell:
> On Wed, 3 Dec 2014, Sven Schreiber wrote:
>
>> Am 03.12.2014 um 16:59 schrieb Allin Cottrell:
>>
>>>
>>> It's more complicated than that, and msortby is actually not doing
>>> anything odd. What's odd, I gather, is the behavior of the Microsoft C
>>> library in the cases you said came out "OK".
>>
>> How can I test the C library behavior? Maybe a simple C code snippet --
>> but compiling on a non-dev Windows machine is tricky I guess?
>
> I tried a little test program on Windows 8. It turns out that the C
> library does return 0 for all comparisons involving a NaN (>, < and
> ==), as it should. Nonetheless, qsort() with our original simple
> callback sorts NaN (invoked via 0.0/0.0) to the start of an array of
> doubles. I don't know how that happens!
sorry for being clueless, but what is qsort() -- gretl's internal call
to a quicksort algorithm perhaps?
qsort is the standard C library quicksort function (defined in
stdlib.h). Gretl calls it for sorting -- we haven't felt a need for
our own quicksort implementation. But to use qsort you need to supply
your own comparison function for the objects you're sorting (what I'm
calling the "callback").
Allin