<cmath> <ctgmath>

islessgreater

islessgreater(x,y)
函式
bool islessgreater (float x      , float y);bool islessgreater (double x     , double y);bool islessgreater (long double x, long double y);
小於或大於
返回 x 是否小於或大於 y

如果一個或兩個引數是NaN,則函式返回 false,但不會引發 FE_INVALID 異常(注意,在這種情況下,表示式 x<y||x>y 可能會引發此類異常)。

在 C 語言中,這被實現為一個返回 int 值的宏。 xy 的型別都應為 floatdoublelong double
在 C++ 中,它透過針對每種浮點型別的函式過載實現,每個過載都返回一個 bool 值。

引數

x, y
要比較的值。

返回值

(x)<(y)||(x)>(y) 相同
如果 x 小於或大於 y,則為 true (1)。
否則為 false (0)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* islessgreater example */
#include <stdio.h>      /* printf */
#include <math.h>       /* islessgreater, log */

int main ()
{
  double result;
  result = log (10.0);

  if (islessgreater(result,0.0))
    printf ("log(10.0) is not zero");
  else
    printf ("log(10.0) is zero");

  return 0;
}

輸出

log(10.0) is not zero


另見