Namespaces
Variants

isnormal

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
(C99)
(C99)
isnormal
(C99)
(C99)
(C23)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
定义于头文件 <math.h>
#define isnormal(arg) /* implementation defined */
(C99 起)

判断给定的浮点数 arg 是否为规范浮点数,即既非零、非次正规数、非无穷大也非 NaN 。该宏返回一个整型值。

FLT_EVAL_METHOD 将被忽略:即使参数以比其类型更高的范围和精度进行计算,也会首先转换为其语义类型,分类基于该类型进行。

目录

参数

arg - 浮点数值

返回值

arg 为正常值则返回非零整数值, 0 否则。

示例

#include <float.h>
#include <math.h>
#include <stdio.h>
int main(void)
{
    printf("isnormal(NAN)         = %d\n", isnormal(NAN));
    printf("isnormal(INFINITY)    = %d\n", isnormal(INFINITY));
    printf("isnormal(0.0)         = %d\n", isnormal(0.0));
    printf("isnormal(DBL_MIN/2.0) = %d\n", isnormal(DBL_MIN / 2.0));
    printf("isnormal(1.0)         = %d\n", isnormal(1.0));
}

输出:

isnormal(NAN)         = 0
isnormal(INFINITY)    = 0
isnormal(0.0)         = 0
isnormal(DBL_MIN/2.0) = 0
isnormal(1.0)         = 1

参考文献

  • C23 标准 (ISO/IEC 9899:2024):
  • 7.12.3.5 isnormal 宏 (页: TBD)
  • C17 标准 (ISO/IEC 9899:2018):
  • 7.12.3.5 isnormal 宏 (p: TBD)
  • C11 标准 (ISO/IEC 9899:2011):
  • 7.12.3.5 isnormal 宏 (p: 237)
  • C99 标准 (ISO/IEC 9899:1999):
  • 7.12.3.5 isnormal 宏 (页码: 217-218)

参见

对给定的浮点数值进行分类
(函数宏)
检查给定数值是否为有限值
(函数宏)
(C99)
检查给定数值是否为无穷大
(函数宏)
(C99)
检查给定数值是否为 NaN
(函数宏)
C++ 文档 关于 isnormal