atan()、atanf()、atanl()、atan2()、atan2f()、atan2l() - 逆正接の計算

標準

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

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

両方  

形式

#include <math.h>

double atan(double x);
float atan(float x);                  /* C++ only */
long double atan(long double x);      /* C++ only */
float atanf(float x);
long double atanl(long double x);

double atan2(double y, double x);
float atan2(float y, float x);                    /* C++ only */
long double atan2(long double y, long double x);  /* C++ only */
float atan2f(float y, float x);
long double atan2l(long double y, long double x);

機能説明

atan() 関数と atan2() 関数は、それぞれ xy/x の 逆正接を計算します。
注: これらの関数は、IEEE 2 進数浮動小数点形式と 16 進浮動小数点形式の両方で機能します。 IEEE 2 進数浮動小数点の詳細は、IEEE 2 進数浮動小数点を参照してください。
制約事項: atan2f() 関数は、_FP_MODE_VARIABLE フィーチャー・テスト・マクロをサポートしません。

戻り値

-pi/2 ~ pi/2 ラジアンの範囲の値を戻します。

atan2() 関数は、-pi ~ pi ラジアンの範囲の値を戻します。atan2() の両方の引数がゼロの場合、この関数は errno に EDOM を設定し、0 を戻します。正しい値がアンダーフローの原因になった場合には、ゼロが戻され、ERANGE の値が errno に保管されます。

IEEE の特殊な動作: 正常に実行された場合、atan2() は y/x の逆正接を戻します。

atan2() の両方の引数がゼロの場合、この関数は errno に EDOM を設定し、0 を戻します。その他のエラーは起こりません。

CELEBA09
⁄* CELEBA09 *⁄                                   
#include <math.h>                                                               
#include <stdio.h>                                                              
                                                                                
int main(void)                                                                  
{                                                                               
    double a,b,c,d;                                                             
                                                                                
    c = 0.45;                                                                   
    d = 0.23;                                                                   
                                                                                
    a = atan(c);                                                                
    b = atan2(c,d);                                                             
                                                                                
    printf("atan( %f ) = %f¥n", c, a);                                          
    printf("atan2( %f, %f ) = %f¥n", c, d, b);                                  
}                                                                               
出力:
atan( 0.450000 ) = 0.422854
atan2( 0.450000, 0.230000 ) = 1.098299

関連情報