asin()、asinf()、asinl() - 逆正弦の計算

標準

標準/拡張機能 C/C++ 依存項目

ISO C
POSIX.1
XPG4
XPG4.2
ISO/ANSI C++
C99
Single UNIX Specification、バージョン 3
C++ TR1 C99

両方  

形式

#include <math.h>

double asin(double x);
float asin(float x);                  /* C++ only */
long double asin(long double x);      /* C++ only */
float asinf(float x);
long double asinl(long double x);

機能説明

x の逆正弦を、-pi/2 ~ pi/2 ラジアンの範囲で計算します。

x の値は -1 と 1 の間でなければなりません。
注: これらの関数は、IEEE 2 進数浮動小数点形式と 16 進浮動小数点形式の両方で機能します。 IEEE 2 進数浮動小数点の詳細は、IEEE 2 進数浮動小数点を参照してください。

戻り値

x が -1 よりも小さい、または 1 よりも大きい場合、関数は errno に EDOM を設定し、0 を戻します。そうでない場合は、非ゼロ値を戻します。

正しい値がアンダーフローの原因になった場合には、0 が戻され、ERANGE の値が errno に保管されます。

IEEE の特殊な動作: 正常終了した場合、関数は引数 x の逆正弦を戻します。

x が -1 よりも小さい、または 1 よりも大きい場合、関数は errno に EDOM を設定し、NaNQ を戻します。その他のエラーは発生しません。

CELEBA07
⁄* CELEBA07                                      

   This example prompts for a value for x.                                      
   It prints an error message if x is greater than 1 or                         
   less than -1; otherwise, it assigns the arcsine of                           
   x to 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: %f too large for asin¥n", x );                              
  else if ( x < MIN )                                                           
    printf( "Error: %f too small for asin¥n", x );                              
  else {                                                                        
    y = asin( x );                                                              
    printf( "asin( %f ) = %f¥n", x, y );                                        
  }                                                                             
}                                                                               
出力:
Enter x
 0.2 is entered
asin( 0.200000 ) = 0.201358

関連情報