當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C語言 isunordered用法及代碼示例

C語言math頭文件(math.h)中isunordered宏的用法及代碼示例。

用法:

isunordered(x,y)
無序
返回是否x或者y無序值

如果一個或兩個參數都是NaN,參數是無序的,函數返回true。在任何情況下,該函數都不會引發FE_INVALID例外。

在C語言中,這是作為返回一個宏的宏實現的int價值。兩者的類型xy應該floatdouble或者long double
在C++中,每個函數都通過函數重載來實現浮點型,每個返回一個bool值。

參數

x, y
用於檢查它們是否無序的值。

返回值

true(1)(如果有)x或者yN
false(0) 否則。

示例

/* isunordered example */
#include <stdio.h>      /* printf */
#include <math.h>       /* isunordered, sqrt */

int main ()
{
  double result;
  result = sqrt (-1.0);

  if (isunordered(result,0.0))
    printf ("sqrt(-1.0) and 0.0 cannot be ordered");
  else
    printf ("sqrt(-1.0) and 0.0 can be ordered");

  return 0;
}


輸出:

sqrt(-1.0) and 0.0 cannot be ordered

相關用法


注:本文由純淨天空篩選整理自C標準庫大神的英文原創作品 C isunordered function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。