標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#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 よりも大きい場合、関数は errno に EDOM を設定し、0 を戻します。そうでない場合は、非ゼロ値を戻します。
正しい値がアンダーフローの原因になった場合には、0 が戻され、ERANGE の値が errno に保管されます。
IEEE の特殊な動作: 正常終了した場合、関数は引数 x の逆正弦を戻します。
x が -1 よりも小さい、または 1 よりも大きい場合、関数は errno に EDOM を設定し、NaNQ を戻します。その他のエラーは発生しません。
⁄* 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