MathClassify

Determiniert den Typ einer reellen Zahl und gibt ein Ergebnis als Wert aus der Enumeration ENUM_FP_CLASS zurück.

ENUM_FP_CLASS  MathClassify(
   double  value      // reelle Zahl
   );

Parameter

value

[in]  Die zu prüfende reelle Zahl

Rückgabewert

Ein Wert aus der Enumeration ENUM_FP_CLASS

ENUM_FP_CLASS

ID

Beschreibung

FP_SUBNORMAL

Eine anormale Zahl, die näher Null ist, als die kleinst mögliche normale Zahl DBL_MIN (2.2250738585072014e-308)

FP_NORMAL

Ein normale Zahl im Bereich von 2.2250738585072014e-308 bis 1.7976931348623158e+308

FP_ZERO

Eine positive oder negativ Null

FP_INFINITE

Eine Zahl, die nicht durch einen entsprechenden Typ dargestellt werden kann, Minus- oder Plus-Unendlich

FP_NAN

Das ist keine Zahl

Beispiel:

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

Siehe auch

Reelle Zahlen (double, float), MathIsValidNumber