# C programming expm1,expm1f and expm1l math.h

In C programming the <math.h> expm1,expm1f and expm1l function compute the exponential of the argument minus 1.The declaration of the functions are given below.

1 float expm1(float x);
2 double expm1(double x);
3 long double expm1(long double x);
4 float expm1f(float x);
5 long double expm1l(long double x);

Parameters:
x – A floating point value.

Return type
floating point -The base-2 exponential value of x minus 1.

All the functions are the same,they compute the base-2 exponential of ‘x’ minus 1.The 1st,2nd and the 3rd function have the same name i.e.’expm1′.The 4th and 5th function have different names.What does having a different names mean is explained in detail below.

Some points to note:
i) expm1( x ) is same as ex-1 .

ii)If x is very large range error occur.In MinGW 6.1 and VS 2015,if x=> 710 the range error seem to occur.

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.

Code example

double d=12 , x1=711 ;

float f=12 ;

long double ld=12 ;

printf(“%lf”, expm1( d ) ) ; //calls the 2nd version
printf(“\n%f”, expm1( f ) ) ; //calls the 1st version
printf(“\n%Lf”, expm1( ld ) ) ;//calls the 3rd version

printf(“\n%lf”, expm1( x1 ) ) ;
printf(“\n%lf”, expm1(INFINITY) ) ;

Output in Visual Studio,

162753.791419
162753.791419
162753.791419
inf
inf

For x1 argument the output is ‘inf'(infinity) and the macro ‘INFINITY’ represent the value ‘infinity’,for this also the output is ‘inf’.

#### expm1f

The ‘expm1f‘ function is same as the 1st function.This means the parameter and return type of the function is float type.The ‘f‘ character appended to ‘expm1f‘ stands for float and it signify the parameter and return type of the function.

Code example

float x=70 ;

printf(“%f”, expm1( x ) ); //Calls the 1st version
printf(“\n%f”, expm1f( 70 ) ); Calls the 4th version

Output,

2515438700355917897481630777344.000000
2515438700355917897481630777344.000000

#### expm1l

The ‘expm1l‘ function is same as the 3rd function.This means the parameter and return type of the function is long double type.The ‘l‘ character appended to ‘expm1l‘ stands for long double and it signify the parameter and return type of the function.

Code example

long double x= 70 ;

printf(“%Lf”, expm1( x ) ); //Calls the 3rd version
printf(“\n%Lf”, expm1l( 70 ) ); //Calls the 5th version

Output,

2515438670919166879789330989056.000000
2515438670919166879789330989056.000000

Can you guess why the output of expm1(long double),expm1l and expm1(float),expm1f are different?