On Fri, Apr 21, 2006 at 08:32:18AM +0200, Michael Kerrisk wrote:
> > Tags: upstream patch
>
> Looks like this is intended for me?
Yea :)
> What man page is this intended for?
qsort()
> > Included is a sample program that demonstrates how to sort IEEE
> > floating point values, including NAN and friends, in a useful way;
> > please consider including it.
> >
> > // make CFLAGS='-W -Wall -O3 -g -std=gnu99' LDFLAGS=-lm fpnansort
> > #include <math.h>
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <assert.h>
> >
> > int fpcomp(const void *a, const void *b)
> > {
> > double x=*(double *)a,
> > y=*(double *)b;
> >
> > if (x<y) return -1;
> > else if (x>y) return 1;
> > // The not-normal values will be grouped together, but
> > // otherwise unordered:
> > else if (!isnormal(x)) return 1;
> > else if (!isnormal(y)) return -1;
>
> Why isnormal()?
"Why not" ?
Seriously, I want all the IEEE special number foo to get out of my
way, and this does wha tI want.
> > assert(x==y);
>
> What is assert doing here?
Well, the current qsort() example uses assert() on argc, so why not?
Seriously, I *think* that x==y is guaranteed, since x and y are both
"normal" values, but there might be other special cases of which I'm
not even aware; this is as way of checking for them, and at the same
time indicating my intent. (Actually, "subnormal" may just be that
case .. will think about it.)
Justin
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]