<cmath> <ctgmath>

islessequal

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

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

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

引數

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
/* islessequal example */
#include <stdio.h>      /* printf */
#include <math.h>       /* islessequal, log */

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

  if (islessequal(result,0.0))
    printf ("log(10.0) is not positive");
  else
    printf ("log(10.0) is positive");

  return 0;
}

輸出

log(10.0) is positive


另見