function exp( x ) {
	var hi;
	var lo;
	var k;

	if ( isnan( x ) || x === PINF ) {
		return x;
	}
	if ( x === NINF ) {
		return 0.0;
	}
	if ( x > OVERFLOW ) {
		return PINF;
	}
	if ( x < UNDERFLOW ) {
		return 0.0;
	}
	if (
		x > NEG_NEARZERO &&
		x < NEARZERO
	) {
		return 1.0 + x;
	}
	// Reduce and compute `r = hi - lo` for extra precision...
	if ( x < 0.0 ) {
		k = trunc( (LOG2_E*x) - 0.5 );
	} else {
		k = trunc( (LOG2_E*x) + 0.5 );
	}
	hi = x - (k*LN2_HI);
	lo = k * LN2_LO;

	return expmulti( hi, lo, k );
}
Evaluates the natural exponential function.

## Method

1.  We reduce \\( x \\) to an \\( r \\) so that \\( |r| \leq 0.5 \cdot \ln(2) \approx 0.34658 \\). Given \\( x \\), we find an \\( r \\) and integer \\( k \\) such that

    ```tex
    \begin{align*}
    x &= k \cdot \ln(2) + r \\
    |r| &\leq 0.5 \cdot \ln(2)
    \end{align*}
    ```

    <!-- <note> -->

    \\( r \\) can be represented as \\( r = \mathrm{hi} - \mathrm{lo} \\) for better accuracy.

    <!-- </note> -->

2.  We approximate of \\( e^{r} \\) by a special rational function on the interval \\(\[0,0.34658]\\):

    ```tex
    \begin{align*}
    R\left(r^2\right) &= r \cdot \frac{ e^{r}+1 }{ e^{r}-1 } \\
    &= 2 + \frac{r^2}{6} - \frac{r^4}{360} + \ldots
    \end{align*}
    ```

    We use a special Remes algorithm on \\(\[0,0.34658]\\) to generate a polynomial of degree \\(5\\) to approximate \\(R\\). The maximum error of this polynomial approximation is bounded by \\(2^{-59}\\). In other words,

    ```tex
    R(z) \sim 2 + P_1 z + P_2 z^2 + P_3 z^3 + P_4 z^4 + P_5 z^5
    ```

    where \\( z = r^2 \\) and

    ```tex
    \left|  2 + P_1 z + \ldots + P_5 z^5  - R(z) \right| \leq 2^{-59}
    ```

    <!-- <note> -->

    The values of \\( P_1 \\) to \\( P_5 \\) are listed in the source code.

    <!-- </note> -->

    The computation of \\( e^{r} \\) thus becomes

    ```tex
    \begin{align*}
    e^{r} &= 1 + \frac{2r}{R-r} \\
          &= 1 + r + \frac{r \cdot R_1(r)}{2 - R_1(r)}\ \text{for better accuracy}
    \end{align*}
    ```

    where

    ```tex
    R_1(r) = r - P_1\ r^2 + P_2\ r^4 + \ldots + P_5\ r^{10}
    ```

3.  We scale back to obtain \\( e^{x} \\). From step 1, we have

    ```tex
    e^{x} = 2^k e^{r}
    ```

## Special Cases

```tex
\begin{align*}
e^\infty &= \infty \\
e^{-\infty} &= 0 \\
e^{\mathrm{NaN}} &= \mathrm{NaN} \\
e^0 &= 1\ \mathrm{is\ exact\ for\ finite\ argument\ only}
\end{align*}
```

## Notes

-   According to an error analysis, the error is always less than \\(1\\) ulp (unit in the last place).

-   For an IEEE double,

    -   if \\(x > 7.09782712893383973096\mbox{e+}02\\), then \\(e^{x}\\) overflows
    -   if \\(x < -7.45133219101941108420\mbox{e+}02\\), then \\(e^{x}\\) underflows

-   The hexadecimal values included in the source code are the intended ones for the used constants. Decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the intended hexadecimal values.

@param {number} x - input value
@returns {number} function value

@example
var v = exp( 4.0 );
// returns ~54.5982

@example
var v = exp( -9.0 );
// returns ~1.234e-4

@example
var v = exp( 0.0 );
// returns 1.0

@example
var v = exp( NaN );
// returns NaN