# C++ cmath expm1, expm1f expm1l function

The C++ cmath expm1, expm1f and expm1l function compute the exponential of the argument minus 1.The declaration of the functions are given below.

Parameters:
x – A floating point value.

Return type
Floating point -The base-e exponential of x minus 1.

The first function is called if the argument is float type.

The second function is called if the argument is double type.

The third function is called if the argument is long double type.

The 4th and 5th function arfe discussed below.

Some points to note:

i) expm1(x) is same as ex-1.

ii)If x is very large Range error occurs. In case of ‘long double expm1(long double x)’ and using the MinGW/Gcc 8.1 and VS 2015, if x=> 710 the range error seem to occur. For expm1f and expm1l the value where Range error occurs vary. Their respective values are given later.

iii)If x is small , x=<-15 the function returns -1.

iv) If NAN is passed ‘nan’ is returned.If INFINITY is passed ‘infinity’ is returned.

v)If integer or character is passed the second version is called-the double version.

```/*Passing floating point value*/
cout&lt;&lt; “expm1(3)=” &lt;&lt; expm1(3) &lt;&lt; endl ;

/*Passing x=710 value*/
cout&lt;&lt; “expm1(710)=” &lt;&lt; expm1(710) &lt;&lt; endl ;

/*Passing x=-15 value*/
cout&lt;&lt; “expm1(-15)=” &lt;&lt; expm1(-15) &lt;&lt; endl ;

/*Passing NAN value*/
cout&lt;&lt; “expm1(NAN)=” &lt;&lt; expm1(NAN) &lt;&lt; endl ;

/*Passing INFINITY value*/
cout&lt;&lt; “expm1(INFINITY)=” &lt;&lt; expm1(INFINITY) &lt;&lt; endl ;
```

Output

expm1(3)= 19.0855
expm1(710)= inf
expm1(-15)= -1
expm1(NAN)= nan
expm1(INFINITY)= infinity

## C++ expm1f

The 4th function expm1f is same as the 1st version float expm1(float). The ‘f‘ character
in ‘expmf’ stands for ‘float’ which signify the argument and return type of the function.

The expm1f accept only float type argument. If the argument is not a float type then it is converted to float type.

If any argument larger than 88 is passed the Range error occurs.

```cout&lt;&lt; expm1f( (double)17 ) &lt;&lt; endl ; //calls expm1f

cout&lt;&lt; expm1f( 17 )
&lt;&lt; &quot;\n&quot; &lt;&lt; expm1f( 89 ) ;
```

Output,

2.4155e+07
1.65164e+38
inf

## C++ expm1l

The 5th function expm1l is same as the 3rd function ‘long double expm1(long double)‘. The ‘l‘ character stands for ‘long double’ which signify the argument and return type of the function.

The expm1l accept only long double type argument. If the argument is not long double type then it is converted to long double.

If the argument is greater than 11356 the Range error occurs.

```cout&lt;&lt; expm1l(  (float)23 ) &lt;&lt; endl;

cout&lt;&lt; expm1l( 11356 )
&lt;&lt; &quot;\n&quot; &lt;&lt; expm1l( 11357 ) ;
```

Output

9.7448e+09
7.04915e+4931
inf

##### Side note

If BOOST library is used and the precision is set to 50 ,the smallest value expm1() can compiled is -37.For smaller values the returned value is always -1.