MathClassify

Determina el tipo de un número real y retorna el resultado en forma de valor de la enumeración ENUM_FP_CLASS

ENUM_FP_CLASS  MathClassify(
   double  value      // número real
   );

Parámetros

value

[in]  Número real comprobado

Valor retornado

Valor de la enumeración ENUM_FP_CLASS

ENUM_FP_CLASS

Identificador

Descripción

FP_SUBNORMAL

Número subnormal que se encuentra más próximo a cero que el número normalizado DBL_MIN menor representable (2.2250738585072014e-308)

FP_NORMAL

Número normalizado que se encuentra en el intervalo de 2.2250738585072014e-308 a 1.7976931348623158e+308

FP_ZERO

Cero positivo o negativo

FP_INFINITE

Un número que no puede representarse con el tipo correspondiente, infinito positivo o negativo

FP_NAN

No es un número

Ejemplo:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
 {
//--- test NaN
  double nan=double("nan");
  PrintFormat("Test NaN: %G is %s, MathIsValidNumber(NaN)=%s",
              nan,
              EnumToString(MathClassify(nan)),
              (string)MathIsValidNumber(nan));
//--- test infinity
  double inf=double("inf");
  PrintFormat("Test Inf: %G is %s, MathIsValidNumber(inf)=%s",
              inf,
              EnumToString(MathClassify(inf)),
              (string)MathIsValidNumber(inf));
//--- test normal value
  double normal=1.2345e6;
  PrintFormat("Test Normal: %G is %s, MathIsValidNumber(normal)=%s",
              normal,
              EnumToString(MathClassify(normal)),
              (string)MathIsValidNumber(normal));
//--- test subnormal value
  double sub_normal=DBL_MIN/2.0;
  PrintFormat("Test Subnormal: %G is %s, MathIsValidNumber(sub_normal)=%s",
              sub_normal,
              EnumToString(MathClassify(sub_normal)),
              (string)MathIsValidNumber(sub_normal));
//--- test zero value
  double zero=0.0/(-1);
  PrintFormat("Test Zero: %G is %s, MathIsValidNumber(zero)=%s",
              zero,
              EnumToString(MathClassify(zero)),
              (string)MathIsValidNumber(zero));
 } 
 /*
 Result:
   Test NaNNAN is FP_NANMathIsValidNumber(NaN)=false
   Test InfINF is FP_INFINITEMathIsValidNumber(inf)=false
   Test Normal1.2345E+06 is FP_NORMALMathIsValidNumber(normal)=true
   Test Subnormal1.11254E-308 is FP_SUBNORMALMathIsValidNumber(sub_normal)=true
   Test Zero: -0 is FP_ZEROMathIsValidNumber(zero)=true
*/ 
//+------------------------------------------------------------------+

Ver también

Tipos reales (double, float), MathIsValidNumber