asin ()- 计算 Arcsine

格式

#include <math.h>
double asin(double x);

语言级别

ANSI

线程安全

描述

asin() 函数计算 x的 arcsine ,范围为-π/2 到 π/2 弧度。

返回值

asin() 函数返回 x的 arcsine。 x 的值必须介于 -1 和 1 之间。 如果 x 小于 -1 或大于 1,则 asin() 函数会将 errno 设置为 EDOM 并返回 0 值。

示例

此示例提示输入 x的值。 如果 x 大于 1 或小于 -1 ,则会打印错误信息;否则,会将 x 的弧余弦赋值给 y
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
 
#define MAX  1.0
#define MIN -1.0
 
int main(void)
{
  double x, y;
 
  printf( "Enter x\n" );
  scanf( "%lf", &x );
 
  /* Output error if not in range */
  if ( x > MAX )
    printf( "Error: %lf too large for asin\n", x );
  else if ( x < MIN )
    printf( "Error: %lf too small for asin\n", x );
  else
  {
    y = asin( x );
    printf( "asin( %lf ) = %lf\n", x, y );
  }
}
 
/****************  Output should be similar to  ******************
Enter x
asin( 0.200000 ) = 0.201358
*/

相关信息