MathClassify

Détermine le type d'un nombre réel et renvoie un résultat sous forme de valeur de l'énumération ENUM_FP_CLASS

ENUM_FP_CLASS  MathClassify(
   double  value      // nombre réel
   );

Paramètres

value

[in] Le nombre réel à vérifier

Valeur de Retour

Une valeur de l'énumération ENUM_FP_CLASS

ENUM_FP_CLASS

ID

Description

FP_SUBNORMAL

Un nombre sous-normal plus proche de zéro que le plus petit nombre normal représentable DBL_MIN (2.2250738585072014e-308)

FP_NORMAL

Un nombre normal compris entre 2,2250738585072014e-308 et 1,7976931348623158e+308

FP_ZERO

Un zéro positif ou négatif

FP_INFINITE

Un nombre qui ne peut pas être représenté par le type approprié, l'infini positif ou négatif

FP_NAN

Pas un chiffre.

Exemple:

//+------------------------------------------------------------------+
//| 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
*/ 
//+------------------------------------------------------------------+

Voir aussi

Types réels (double, flottant), MathIsValidNumber