In the latest C++ standard, I noticed the following macros :
bool isgreater(float x, float y);
bool isgreaterequal(float x, float y);
bool isless(float x, float y);
bool islessequal(float x, float y);
bool islessgreater(float x, float y);
bool isunordered(float x, float y);
These macros are from C (7.12.14 and 7.12.14).
So, why would someone use these macros, instead of operators? Is there anything special that these macros are doing (like checking for inf), or are they the same as their corresponding operator?
C++ example :
#include <iostream>
#include <cmath>
int main()
{
float x=0.2;
float y=0.5;
std::cout << x << " < " << y << " : " << std::boolalpha << std::islessequal( x, y ) << std::endl;
std::cout << x << " < " << y << " : " << std::boolalpha << ( x <= y ) << std::endl;
}
Unlike the relational operators, these macros do really only return a boolean value and do never raise any floating point exception.
In short: You only have to deal with
true/falseand nothing else.references:
The Open Group descriptions (not the C or C++ standard, but highly relevant in the Unix/Linux world and almost always similar to the standards):
C++ standard:
C standard: