C++ cmath acosh , acoshf and acoshl function

The C++ cmath acosh,acoshf and acoshl function compute the arc hyperbolic cosine of the given value.The declaration of the functions is given below.

1 float acosh(float x);
2 double acosh(double x);
3 long double acosh(long double x);
4 float acoshf(float x);
5 long double acoshl(long double x);

x – A floating point non-negative value.

Return type
floating point value -The returned value is in the interval [0 , +∞].

Some points to note:
i) acosh(x) is same as cosh(x).

ii)The returned value is always +ve.

iii)If the argument is less than 1 a domain error occurs-a ‘nan’ is returned.

iv)If the arguments is integer or character literal the double version is called.

Link: C++ nan

Code example

/*Passing floating point value*/
cout<< acosh(12) << endl ;

/*Passing 1*/
cout<< acosh(1) << endl ;

/*Passing 0*/
cout<< acosh( 0 ) << endl ;

/*Passing -ve value*/
cout<< acosh(-12) << endl ;

/*Passing INFINITY*/
cout<< acosh( INFINITY ) << endl ;



acoshf and acoshl


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

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

Code example

#include <typeinfo>

/*acoshf */
cout<< “*acoshf\n”;
float f=2;
cout<< typeid( acoshf(2) ).name() << endl /*identify type of acoshf retunred value */
<< typeid( acosh(f) ).name() << endl; /*identify type of acosh(float) returned value */

cout<< “*acoshl\n”;
long double ld=2;
cout<< typeid( acoshl(2) ).name() << endl /*indentify type of acoshl returned value */
<< typeid( acosh(ld) ).name() << endl; /*identify type of acosh(long double) returned value*/


e (means ‘long double’)
e (means ‘long double’)