C++ Reference: Standard C++ Library reference: C Library: cmath: isnormal

发布于:2022-10-13 ⋅ 阅读:(528) ⋅ 点赞:(0)

C++官网参考链接:https://cplusplus.com/reference/cmath/isnormal/

宏/函数
<cmath> <ctgmath>
isnormal
C99
宏    
isnormal(x)
C++11
函数 
bool isnormal(float x);
bool isnormal(double x);
bool isnormal(long double x);
是正常的
返回x是否是一个正常值:即,它是否既不是无穷大(infinity),NaN,0,也不是不正常值。 
C99
在C语言中,这被实现为一个返回int值的宏。x的类型应为float、double或long double。
C++11
在C++中,它是通过每个浮点类型(floating-point type)的函数重载来实现的,每个浮点类型都返回bool值。

参数
x
一个浮点值。

返回值
如果x是正常的,则是非0值(true);否则为0(false)。

用例
/* isnormal example */
#include <stdio.h>      /* printf */
#include <math.h>       /* isnormal */

int main()
{
  printf ("isnormal(1.0)    : %d\n",isnormal(1.0));
  printf ("isnormal(0.0)    : %d\n",isnormal(0.0));
  printf ("isnormal(1.0/0.0): %d\n",isnormal(1.0/0.0));
  return 0;
}
输出:

另请参考
isfinite    Is finite value (macro) (是有限值(宏)) 
isinf    Is infinity (macro/function) (是无穷值(宏/函数)) 
isnan    Is Not-A-Number (macro/function) (不是一个数(宏/函数)) 
fpclassify    Classify floating-point value (macro/function) (分类浮点值(宏/函数)) 

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到