名稱空間
變體
操作

atan、atanf、atanl

來自 cppreference.com
< c‎ | 數值‎ | 數學
 
 
 
常用數學函式
函式
基本操作
(C99)
(C99)
(C99)
(C99)(C99)(C99)(C23)
最大值/最小值操作
(C99)
(C99)
指數函式
(C23)
(C99)
(C99)
(C23)
(C23)

(C99)
(C99)(C23)
(C23)
(C23)
冪函式
(C99)
(C23)
(C23)

(C99)
(C23)
(C23)
三角函式和雙曲函式
atan
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
(C99)
(C99)
(C99)
最近整數浮點數
(C99)(C99)(C99)
(C99)

(C99)(C99)(C99)
(C23)(C23)(C23)(C23)
浮點數操作
(C99)(C99)
(C99)(C23)
(C99)
窄化操作
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
量子與量子指數
十進位制重新編碼函式
總序和載荷函式
分類
(C99)
(C99)
(C99)
(C23)
誤差函式和伽馬函式
(C99)
(C99)
(C99)
(C99)
型別
宏常量
特殊浮點值
(C99)(C23)
引數和返回值
錯誤處理
快速操作指示符
 
定義於標頭檔案 <math.h>
float       atanf( float arg );
(1) (C99 起)
double      atan( double arg );
(2)
long double atanl( long double arg );
(3) (C99 起)
_Decimal32  atand32( _Decimal32 arg );
(4) (自 C23 起)
_Decimal64  atand64( _Decimal64 arg );
(5) (自 C23 起)
_Decimal128 atand128( _Decimal128 arg );
(6) (自 C23 起)
定義於標頭檔案 <tgmath.h>
#define atan( arg )
(7) (C99 起)
1-6) 計算 arg 的主值反正切。
7) 泛型宏:若引數型別為 long double,則呼叫 (3) (atanl)。否則,若引數為整數型別或型別為 double,則呼叫 (2) (atan)。否則,呼叫 (1) (atanf)。若引數為複數,則宏呼叫對應的複數函式(catanfcatancatanl)。

函式 (4-6) 僅當實現預定義 __STDC_IEC_60559_DFP__(即實現支援十進位制浮點數)時才宣告。

(自 C23 起)

目錄

[編輯] 引數

arg - 浮點值

[編輯] 返回值

若無錯誤發生,則返回 arg 的反正切(arctan(arg)),以弧度計,在範圍 [-
π
2
 ; +
π
2
]
內。

如果因下溢發生範圍錯誤,則返回正確結果(舍入後)。

[編輯] 錯誤處理

錯誤按 math_errhandling 中指定的方式報告。

如果實現支援 IEEE 浮點算術 (IEC 60559)

  • 如果引數是 ±0,則原樣返回;
  • 若引數為 +∞,則返回 +π/2;
  • 若引數為 -∞,則返回 -π/2;
  • 如果引數為 NaN,則返回 NaN。

[編輯] 注意

POSIX 指定,在下溢情況下,arg 未經修改返回,若不支援則返回不大於 DBL_MINFLT_MINLDBL_MIN 的實現定義值。

[編輯] 示例

#include <math.h>
#include <stdio.h>
 
int main(void)
{
    printf("atan(1) = %f, 4*atan(1)=%f\n", atan(1), 4 * atan(1));
    // special values
    printf("atan(Inf) = %f, 2*atan(Inf) = %f\n", atan(INFINITY), 2 * atan(INFINITY));
    printf("atan(-0.0) = %+f, atan(+0.0) = %+f\n", atan(-0.0), atan(0));
}

輸出

atan(1) = 0.785398, 4*atan(1)=3.141593
atan(Inf) = 1.570796, 2*atan(Inf) = 3.141593
atan(-0.0) = -0.000000, atan(+0.0) = +0.000000

[編輯] 參考

  • C23 標準 (ISO/IEC 9899:2024)
  • 7.12.4.3 atan 函式 (p: 待定)
  • 7.25 型別通用數學 <tgmath.h> (p: TBD)
  • F.10.1.3 atan 函式 (p: 待定)
  • C17 標準 (ISO/IEC 9899:2018)
  • 7.12.4.3 atan 函式 (p: 174)
  • 7.25 型別通用數學 <tgmath.h> (p: 272-273)
  • F.10.1.3 atan 函式 (p: 378)
  • C11 標準 (ISO/IEC 9899:2011)
  • 7.12.4.3 atan 函式 (p: 238-239)
  • 7.25 型別通用數學 <tgmath.h> (p: 373-375)
  • F.10.1.3 atan 函式 (p: 519)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.12.4.3 atan 函式 (p: 219)
  • 7.22 型別通用數學 <tgmath.h> (p: 335-337)
  • F.9.1.3 atan 函式 (p: 456)
  • C89/C90 標準 (ISO/IEC 9899:1990)
  • 4.5.2.3 atan 函式

[編輯] 亦參見

計算反正切,使用符號確定象限
(函式) [編輯]
(C99)(C99)
計算反正弦 (arcsin(x))
(函式) [編輯]
(C99)(C99)
計算反餘弦 (arccos(x))
(函式) [編輯]
(C99)(C99)
計算正切 (tan(x))
(函式) [編輯]
(C99)(C99)(C99)
計算復反正切
(函式) [編輯]
C++ 文件 用於 atan