Namespaces
Variants

INFINITY

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
INFINITY DEC_INFINITY
(C99) (C23)
(C99) (C23)
Arguments and return values
Error handling
Fast operation indicators
헤더 파일에 정의됨 <math.h>
#define INFINITY /*implementation defined*/
(C99부터)

구현체가 부동 소수점 무한대를 지원하는 경우, 매크로 INFINITY 는 양의 무한대 또는 부호 없는 무한대로 평가되는 float 타입의 상수 표현식으로 확장됩니다.

구현체가 부동 소수점 무한대를 지원하지 않는 경우, 매크로 INFINITY 는 컴파일 시간에 float 이 반드시 오버플로우되는 양의 값으로 확장되며, 이 매크로의 사용은 컴파일러 경고를 생성합니다.

무한대를 출력하는 데 사용되는 스타일은 구현에 따라 정의됩니다.

예제

무한대 및 IEEE 형식을 출력하는 데 사용되는 스타일을 표시합니다.

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

가능한 출력:

INFINITY:   inf 7ff0000000000000

참고문헌

  • C11 표준 (ISO/IEC 9899:2011):
  • 7.12/4 INFINITY (p: 231-232)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.12/4 INFINITY (p: 212-213)

참조

(C99)
주어진 숫자가 무한한지 확인
(함수 매크로)
표현 가능한 범위를 초과하는 값(무한대)을 나타냄 float , double long double 각각에 대해
(매크로 상수)
C++ 문서 for INFINITY