Name
isgreater, isgreaterequal
Synopsis
Compares two floating-point values without risking an exception
#include <math.h> intisgreater(x,y); intisgreaterequal(x,y);
The macro isgreater() tests
whether the argument x is greater than
the argument y, but without risking an
exception. Both operands must have real floating-point types. The
result of isgreater() is the same
as the result of the operation (x) > (
y),
but that operation could raise an “invalid operand” exception if
either operand is NaN (“not a number”), in which case neither is
greater than, equal to, or less than the other.
The macro isgreater()
returns a nonzero value (that is, true) if the first argument is greater
than the second; otherwise, it returns 0. The macro isgreaterequal() functions similarly, but
corresponds to the relation (x) >= (
y),
returning true if the first
argument is greater than or equal to the second; otherwise 0.
Example
/* Can a, b, and c be three sides of a triangle? */ double a, b, c, temp; /* First get the longest "side" in a. */ if (isgreater( a, b ) ) temp = a; a = b; b = temp; if (isgreater( a, c ) ) temp = a; a = c; c = temp; /* Then see if a is longer than the sum of the other two sides: */ if (isgreaterequal( a, b + c ) ) printf( "The three numbers %.2lf, %.2lf, and %.2lf " "are not sides of a triangle.\n", a, b, c );
See Also
isless(), islessequal(), islessgreater(), isunordered()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access