In C programming the <math.h> sinh , sinhf and sinhl compute the hyperbolic sine of the argument.The declaration of the functions are given below.
|1 float sinh(float x);|
|2 double sinh(double x);|
|3 long double sinh(long double x);|
|4 float sinhf(float x);|
|5 long double sinhl(long double x);|
x -The value whose hyperbolic sine is to be computed.
floating point value -The hyperbolic sine of ‘x’.
All the functions are the same,they compute the hyperbolic sine of ‘x’.The 1st,2nd and the 3rd function have the same name i.e.’sinh’.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) If the argument is very large Range error occur.In MINGW 6.1 and VS 2015 when x>710 ,Range error seems to occur.
ii)If NAN is passed ‘nan’ is returned.
iii)If INFINITY is passed ‘inf’ is returned.
float f=250 ;
long double ld=250 ;
printf(“%lf”, sinh( d ) ) ; //calls the 2nd version
printf(“\n%f”, sinh( f ) ) ; //calls the 1st version
printf(“\n%Lf”, sinh( ld ) ) ;//calls the 3rd version
printf(“\n%lf”, sinh( x1 ) ) ;
printf(“\n%lf”, sinh(NAN) ) ;
Output in Visual Studio ,
The ‘NAN’ macro stands for the value ‘NaN’.In the 4th output the argument passed is 750 so a range error occur hence ‘inf'(infinity) is the returned value.
Note as the argument value increases the output also increases until it reaches an infinity when the argument value is 711.
The ‘sinhf‘ 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 ‘sinhf‘ stands for float and it signify the parameter and return type of the function.
printf(“%f”, sinh( x ) ); //Calls the 1st version
printf(“\n%f”, sinhf( 123 ) ); Calls the 4th version
The ‘sinhl‘ 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 ‘sinhl‘ stands for long double and it signify the parameter and return type of the function.
printf(“%Lf”, sinh( x ) ); //Calls the 3rd version
printf(“\n%Lf”, sinhl( -30 ) ); //Calls the 5th version
The difference in the accuracy of the output value of sinhl,sinh(long double) and the sinhf,sinh(long double) is a proof that the functions return different data type values.