1 /* 2 Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 3 4 Developed at SunPro, a Sun Microsystems, Inc. business. 5 Permission to use, copy, modify, and distribute this 6 software is freely granted, provided that this notice 7 is preserved. 8 */ 9 /* isgreater.c: This file contains no source code, but rather only the 10 * man-page comments. All of the documented "functions" are actually macros 11 * defined in math.h (q.v.). */ 12 /* 13 FUNCTION 14 <<isgreater>>, <<isgreaterequal>>, <<isless>>, <<islessequal>>, <<islessgreater>>, and <<isunordered>>---comparison macros 15 INDEX 16 isgreater 17 INDEX 18 isgreaterequal 19 INDEX 20 isless 21 INDEX 22 islessequal 23 INDEX 24 islessgreater 25 INDEX 26 isunordered 27 28 SYNOPSIS 29 #include <math.h> 30 int isgreater(real-floating <[x]>, real-floating <[y]>); 31 int isgreaterequal(real-floating <[x]>, real-floating <[y]>); 32 int isless(real-floating <[x]>, real-floating <[y]>); 33 int islessequal(real-floating <[x]>, real-floating <[y]>); 34 int islessgreater(real-floating <[x]>, real-floating <[y]>); 35 int isunordered(real-floating <[x]>, real-floating <[y]>); 36 37 DESCRIPTION 38 <<isgreater>>, <<isgreaterequal>>, <<isless>>, <<islessequal>>, 39 <<islessgreater>>, and <<isunordered>> are macros defined for use in 40 comparing floating-point numbers without raising any floating-point 41 exceptions. 42 43 The relational operators (i.e. <, >, <=, and >=) support the usual mathematical 44 relationships between numeric values. For any ordered pair of numeric 45 values exactly one of the relationships--less, greater, and equal--is 46 true. Relational operators may raise the "invalid" floating-point 47 exception when argument values are NaNs. For a NaN and a numeric value, or 48 for two NaNs, just the unordered relationship is true (i.e., if one or both 49 of the arguments a NaN, the relationship is called unordered). The specified 50 macros are quiet (non floating-point exception raising) versions of the 51 relational operators, and other comparison macros that facilitate writing 52 efficient code that accounts for NaNs without suffering the "invalid" 53 floating-point exception. In the synopses shown, "real-floating" indicates 54 that the argument is an expression of real floating type. 55 56 Please note that saying that the macros do not raise floating-point 57 exceptions, it is referring to the function that they are performing. It 58 is certainly possible to give them an expression which causes an exception. 59 For example: 60 o+ 61 o NaN < 1.0 62 causes an "invalid" exception, 63 o isless(NaN, 1.0) 64 does not, and 65 o isless(NaN*0., 1.0) 66 causes an exception due to the "NaN*0.", but not from the 67 resultant reduced comparison of isless(NaN, 1.0). 68 o- 69 70 RETURNS 71 @comment Formatting note: "$@" forces a new line 72 No floating-point exceptions are raised for any of the macros.@* 73 The <<isgreater>> macro returns the value of (x) > (y).@* 74 The <<isgreaterequal>> macro returns the value of (x) >= (y).@* 75 The <<isless>> macro returns the value of (x) < (y).@* 76 The <<islessequal>> macro returns the value of (x) <= (y).@* 77 The <<islessgreater>> macro returns the value of (x) < (y) || (x) > (y).@* 78 The <<isunordered>> macro returns 1 if either of its arguments is NaN and 0 otherwise. 79 80 PORTABILITY 81 C99, POSIX. 82 83 */ 84