orthogonal sets of floating-point comparison operators <9112041738.AA27446adgh.Eng.Sun.COM>

uunet!cygnus.com!gnu uunet!cygnus.com!gnu
Wed Dec 4 22:38:21 PST 1991


David said:
> The standard C operators == != < <= > >= correspond to an odd subset of
> these [16] comparison operators:
> 
> 	Operator	True if
> 
> 	==		eq
> 	!=		lt gt un
> 	<		lt
> 	<=		lt eq
> 	>		gt
> 	>=		ge

Actually though, they are a perfectly good subset of the original eight.
David mangled the table slightly which makes its regularity unobvious.  Try:

> 	==		eq
> 	!=		lt gt		[un added very late]
> 	<		lt
> 	<=		lt eq
> 	>		gt
> 	>=		gt eq

This is simply the eight possibilities, with "always true" and "always false"
removed.  It's no "odd subset", it's a complete list.

Just because IEEE saw fit to complicate math with unorderedness, is no
reason to screw up programming language syntax.  I know that lots of
people are itching to out-Stroustroup Stroustroup and make an even
more horrible mess of C syntax than C++.  Let's resist.

If little pieces of numerical analyst code need to tell if something is
a NaN, let them test for it explicitly, with a function call -- leaving
the rest of us blissfully ignorant of the complications.

	John Gilmore



More information about the Numeric-interest mailing list