Namespaces
Variants

NAN

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
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
NAN DEC_NAN
(C99) (C23)
Arguments and return values
Error handling
Fast operation indicators
헤더 파일에 정의됨 <math.h>
#define NAN /*implementation defined*/
(C99부터)

매크로 NAN float 타입의 상수 표현식으로 확장되며, 이는 조용한 난수(quiet not-a-number, QNaN) 값으로 평가됩니다. 구현체가 QNaN을 지원하지 않는 경우, 이 매크로 상수는 정의되지 않습니다.

NaN을 출력하는 데 사용되는 스타일은 구현에 따라 정의됩니다.

목차

참고 사항

다양한 페이로드와 부호 비트로 구분되는 여러 다른 NaN 값들이 존재합니다. 매크로 NAN 에 의해 생성되는 NaN의 페이로드 내용과 부호 비트는 구현에 따라 정의됩니다.

예제

NaN 및 IEEE 형식을 출력하는 데 사용된 스타일을 표시합니다.

#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
    const double f = NAN;
    uint64_t fn;
    memcpy(&fn, &f, sizeof f);
    printf("NAN:   %f %" PRIx64 "\n", f, fn);
}

가능한 출력:

NAN:   nan 7ff8000000000000

참고문헌

  • C23 표준 (ISO/IEC 9899:2024):
  • 7.12/5 NAN (p: TBD)
  • F.10/11/13 NAN (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018):
  • 7.12/5 NAN (p: TBD)
  • F.10/11/13 NAN (p: TBD)
  • C11 표준 (ISO/IEC 9899:2011):
  • 7.12/5 NAN (p: 232)
  • F.10/11/13 NAN (p: 518)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.12/5 NAN (p: 213)
  • F.9/11/13 NAN (p: 455)

참고 항목

(C99) (C99) (C99)
NaN(숫자가 아님)을 반환합니다
(함수)
(C99)
주어진 숫자가 NaN인지 확인합니다
(함수 매크로)