Namespaces
Variants

exp, expf, expl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
exp
(C23)
(C99)
(C99)
(C23)
(C23)

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
Arguments and return values
Error handling
Fast operation indicators
Definiert im Header <math.h>
float expf ( float arg ) ;
(1) (seit C99)
double exp ( double arg ) ;
(2)
long double expl ( long double arg ) ;
(3) (seit C99)
Definiert im Header <tgmath.h>
#define exp( arg )
(4) (seit C99)
1-3) Berechnet e ( Eulersche Zahl , 2.7182818 ... ) potenziert mit dem gegebenen Wert arg .
4) Typgenerisches Makro: Wenn arg den Typ long double hat, wird expl aufgerufen. Andernfalls, wenn arg einen Ganzzahltyp oder den Typ double hat, wird exp aufgerufen. Andernfalls wird expf aufgerufen. Wenn arg komplex oder imaginär ist, ruft das Makro die entsprechende komplexe Funktion auf ( cexpf , cexp , cexpl ).

Inhaltsverzeichnis

Parameter

arg - Gleitkommawert

Rückgabewert

Wenn keine Fehler auftreten, wird die Basis- e -Exponentialfunktion von arg ( e arg
) zurückgegeben.

Wenn ein Bereichsfehler aufgrund von Überlauf auftritt, +HUGE_VAL , +HUGE_VALF , oder +HUGE_VALL wird zurückgegeben.

Wenn ein Bereichsfehler aufgrund von Unterlauf auftritt, wird das korrekte Ergebnis (nach Rundung) zurückgegeben.

Fehlerbehandlung

Fehler werden gemeldet, wie in math_errhandling festgelegt.

Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt,

  • Wenn das Argument ±0 ist, wird 1 zurückgegeben
  • Wenn das Argument -∞ ist, wird +0 zurückgegeben
  • Wenn das Argument +∞ ist, wird +∞ zurückgegeben
  • Wenn das Argument NaN ist, wird NaN zurückgegeben

Hinweise

Für IEEE-kompatible Typen double ist Overflow garantiert, wenn 709.8 < arg , und Underflow ist garantiert, wenn arg < -708.4 .

Beispiel

#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
// #pragma STDC FENV_ACCESS ON
int main(void)
{
    printf("exp(1) = %f\n", exp(1));
    printf("FV of $100, continuously compounded at 3%% for 1 year = %f\n",
            100*exp(0.03));
    // special values
    printf("exp(-0) = %f\n", exp(-0.0));
    printf("exp(-Inf) = %f\n", exp(-INFINITY));
    //error handling
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("exp(710) = %f\n", exp(710));
    if (errno == ERANGE)
        perror("    errno == ERANGE");
    if (fetestexcept(FE_OVERFLOW))
        puts("    FE_OVERFLOW raised");
}

Mögliche Ausgabe:

exp(1) = 2.718282
FV of $100, continuously compounded at 3% for 1 year = 103.045453
exp(-0) = 1.000000
exp(-Inf) = 0.000000
exp(710) = inf
    errno == ERANGE: Numerical result out of range
    FE_OVERFLOW raised

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12.6.1 Die exp-Funktionen (S: TBD)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: TBD)
  • F.10.3.1 Die exp-Funktionen (S: TBD)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12.6.1 Die exp-Funktionen (S. 175)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S. 272-273)
  • F.10.3.1 Die exp-Funktionen (S. 379)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12.6.1 Die exp-Funktionen (S. 242)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S. 373-375)
  • F.10.3.1 Die exp-Funktionen (S. 520)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12.6.1 Die exp-Funktionen (S. 223)
  • 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
  • F.9.3.1 Die exp-Funktionen (S. 458)
  • C89/C90-Standard (ISO/IEC 9899:1990):
  • 4.5.4.1 Die exp-Funktion

Siehe auch

(C99) (C99) (C99)
berechnet 2 potenziert mit dem gegebenen Exponenten ( 2 x )
(Funktion)
(C99) (C99) (C99)
berechnet e potenziert mit dem gegebenen Exponenten, minus eins ( e x -1 )
(Funktion)
(C99) (C99)
berechnet den natürlichen (Basis- e ) Logarithmus ( ln(x) )
(Funktion)
(C99) (C99) (C99)
berechnet die komplexe Basis-e Exponentialfunktion
(Funktion)