Comparison Macros

Document: N1449
Date: 10 May-10
Author: P.J. Plauger

In 7.12.14 Comparison Macros, the Working Draft currently define the macros:
int isgreater(real-floating x, real-floating y);
int isgreaterequal(real-floating x, real-floating y);
int isless(real-floating x, real-floating y);
int islessequal(real-floating x, real-floating y);
int islessgreater(real-floating x, real-floating y);
int isunordered(real-floating x, real-floating y);
All we say in the preamble to this clause is:
In the synopses in this subclause, real-floating indicates that the argument shall be an expression of real floating type.
Nothing is said, one way or the other, about whether the two arguments must have the same real-floating type. But in the C++ Standard, clause 26.8 para. 12, the analogous templates are:
template <class T> bool isgreater(T x, T y);
template <class T> bool isgreaterequal(T x, T y);
template <class T> bool isless(T x, T y);
template <class T> bool islessequal(T x, T y);
template <class T> bool islessgreater(T x, T y);
template <class T> bool isunordered(T x, T y);
which comes down on the side of same-type arguments. We have two choices:
  1. Clarify in the C standard that the arguments must have the same-type, or at least that it is implementation defined what happens if they do not.
  2. Clarify in the C standard that the arguments may have different types, and file a comment against the current C++ FCD that the templates should be changed to:
    template <class T, class U> bool isgreater(T x, U y);
    etc.
The consensus from Florence is for the second choice. (The fix for C++ is not exactly right, but that is not of concern to C.) I believe it is sufficient to add, after the sentence quoted above:
The two arguments to each function need not be of the same real floating type.
The description of the functions that follow are clear enough that the usual arithmetic conversions will be applied in any comparison to bring the two operands to the common real type.