C ++ expm1 () - C ++ Standardbibliothek

Die Funktion expm1 () in C ++ gibt das Exponential (Eulers Zahl) e zurück, das auf das angegebene Argument minus 1 angehoben wird.

Die Funktion ist in der Header-Datei definiert.

(Mathematik) e x - 1 = expm1 (x) (C ++ - Programmierung)

expm1 () Prototyp (Stand C ++ 11 Standard)

double expm1 (double x); float expm1 (float x); long double expm1 (long double x); doppelt expm1 (T x); // Hier ist T ein ganzzahliger Typ.

expm1 () Parameter

Die Funktion expm1 () akzeptiert ein einzelnes obligatorisches Argument (kann positiv, negativ oder 0 sein).

expm1 () Rückgabewert

Die Funktion expm1 () gibt den Wert im Bereich von (-1, ∞) zurück .

Wenn die Größe des Ergebnisses zu groß ist, um durch einen Wert des Rückgabetyps dargestellt zu werden, wird die Funktion HUGE_VALmit dem richtigen Vorzeichen zurückgegeben, und es tritt ein Überlaufbereichsfehler auf.

Beispiel 1: Wie funktioniert expm1 ()?

 #include #include using namespace std; int main() ( double x = 2.19, result; result = expm1(x); cout << "e^" << x << " - 1 = " << result << endl; return 0; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 e 2,19-1 = 7,93521

Beispiel 2: expm1 () mit integriertem Typ

 #include #include using namespace std; int main() ( int x = 4; double result; result = expm1(x); cout << "e^" << x << " - 1 = " << result << endl; return 0; )

Wenn Sie das Programm ausführen, lautet die Ausgabe wie folgt:

 e 4 - 1 = 53,5982

Interessante Beiträge...