sinh, sinhf, sinhl

< c‎ | numeric‎ | math
在标头 <math.h> 定义
float       sinhf( float arg );
(1) (C99 起)
double      sinh( double arg );
(2)
long double sinhl( long double arg );
(3) (C99 起)
在标头 <tgmath.h> 定义
#define sinh( arg )
(4) (C99 起)
1-3) 计算 arg 的双曲正弦。
4) 泛型宏:若实参拥有 long double 类型,则调用 sinhl。否则,若实参拥有整数类型或 double 类型,则调用 sinh。否则调用 sinhf。若实参为复数,则宏调用对应的复数函数(csinhfcsinhcsinhl)。

参数

arg - 表示双曲角的浮点值

返回值

若不出现错误,则返回 arg 的双曲正弦(sinh(arg)
earg
-e-arg
2
)。

若出现上溢所致的值域错误,则返回 ±HUGE_VAL±HUGE_VALF±HUGE_VALL

若出现下溢所致的值域错误,则返回(舍入后的)正确结果。

错误处理

报告 math_errhandling 中指定的错误。

若实现支持 IEEE 浮点算术(IEC 60559),则

  • 若实参为 ±0 或 ±∞,则返回未修改的实参
  • 若实参为 NaN,则返回 NaN

注解

POSIX 指定在下溢情况下,返回不修改的 arg,而若不支持如此,则返回不大于 DBL_MINFLT_MINLDBL_MIN 的实现定义值。

示例

#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
// #pragma STDC FENV_ACCESS ON
 
int main(void)
{
    printf("sinh(1) = %f\nsinh(-1)=%f\n", sinh(1), sinh(-1));
    printf("log(sinh(1) + cosh(1))=%f\n", log(sinh(1) + cosh(1)));
 
    // 特殊值
    printf("sinh(+0) = %f\nsinh(-0)=%f\n", sinh(0.0), sinh(-0.0));
 
    // 错误处理
    errno=0; feclearexcept(FE_ALL_EXCEPT);
    printf("sinh(710.5) = %f\n", sinh(710.5));
    if (errno == ERANGE)
        perror("    errno == ERANGE");
    if (fetestexcept(FE_OVERFLOW))
        puts("    FE_OVERFLOW raised");
}

可能的输出:

sinh(1) = 1.175201
sinh(-1)=-1.175201
log(sinh(1) + cosh(1))=1.000000
sinh(+0) = 0.000000
sinh(-0)=-0.000000
sinh(710.5) = inf
    errno == ERANGE: Numerical result out of range
    FE_OVERFLOW raised

引用

  • C23 标准(ISO/IEC 9899:2024):
  • 7.12.5.5 The sinh functions (第 TBD 页)
  • 7.25 Type-generic math <tgmath.h> (第 TBD 页)
  • F.10.2.5 The sinh functions (第 TBD 页)
  • C17 标准(ISO/IEC 9899:2018):
  • 7.12.5.5 The sinh functions (第 176 页)
  • 7.25 Type-generic math <tgmath.h> (第 272-273 页)
  • F.10.2.5 The sinh functions (第 379 页)
  • C11 标准(ISO/IEC 9899:2011):
  • 7.12.5.5 The sinh functions (第 241-242 页)
  • 7.25 Type-generic math <tgmath.h> (第 373-375 页)
  • F.10.2.5 The sinh functions (第 520 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.12.5.5 The sinh functions (第 222 页)
  • 7.22 Type-generic math <tgmath.h> (第 335-337 页)
  • F.9.2.5 The sinh functions (第 457 页)
  • C89/C90 标准(ISO/IEC 9899:1990):
  • 4.5.3.2 The sinh function

参阅

(C99)(C99)
计算双曲余弦(cosh(x)
(函数)
(C99)(C99)
计算双曲正切(tanh(x)
(函数)
(C99)(C99)(C99)
计算反双曲正弦(arsinh(x)
(函数)
(C99)(C99)(C99)
计算复数双曲正弦
(函数)