Namespaces
Variants

HUGE_VALF, HUGE_VAL, HUGE_VALL

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
HUGE_VAL HUGE_VALF HUGE_VALL HUGE_VALD N
(C99) (C99) (C23)
Arguments and return values
Error handling
Fast operation indicators
Definido en el encabezado <math.h>
#define HUGE_VALF /*implementation defined*/
(desde C99)
#define HUGE_VAL  /*implementation defined*/
#define HUGE_VALL /*implementation defined*/
(desde C99)

Las macros HUGE_VALF , HUGE_VAL y HUGE_VALL se expanden a expresiones constantes de punto flotante positivas que comparan igual a los valores devueltos por funciones y operadores de punto flotante en caso de desbordamiento (consulte math_errhandling ).

Constante Explicación
HUGE_VALF Se expande a una expresión float positiva que indica desbordamiento
HUGE_VAL Se expande a una expresión double positiva que indica desbordamiento, no necesariamente representable como float
HUGE_VALL Se expande a una expresión long double positiva que indica desbordamiento, no necesariamente representable como float o double

En implementaciones que admiten infinitos de punto flotante, estas macros siempre se expanden a los infinitos positivos de float , double , y long double , respectivamente.

Ejemplo

#include <math.h>
#include <stdio.h>
int main(void)
{
    const double result = 1.0 / 0.0;
    printf("1.0/0.0 == %f\n", result);
    if (result == HUGE_VAL)
        puts("1.0/0.0 == HUGE_VAL");
}

Salida posible:

1.0/0.0 == inf
1.0/0.0 == HUGE_VAL

Referencias

  • Estándar C23 (ISO/IEC 9899:2024):
  • 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD)
  • F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD)
  • Estándar C17 (ISO/IEC 9899:2018):
  • 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD)
  • F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD)
  • Estándar C11 (ISO/IEC 9899:2011):
  • 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 231)
  • F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 517)
  • Estándar C99 (ISO/IEC 9899:1999):
  • 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 212)
  • F.9/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 454)
  • Estándar C89/C90 (ISO/IEC 9899:1990):
  • 4.5 HUGE_VAL

Véase también

evalúa a infinito positivo o el valor garantizado para desbordar un float
(macro constante)