?
This document uses PHP Chinese website manual Release
在頭文件<math.h>中定義 | ||
---|---|---|
float acosf( float arg ); | (1) | (since C99) |
double acos( double arg ); | (2) | |
long double acosl( long double arg ); | (3) | (since C99) |
Defined in header <tgmath.h> | ||
#define acos( arg ) | (4) | (since C99) |
1-3)計算反余弦的主值arg
。
4)類型 - 通用宏:如果參數(shù)具有類型long double
,acosl
則被調(diào)用。否則,如果參數(shù)具有整數(shù)類型或類型double
,acos
則調(diào)用該參數(shù)。否則,acosf
被調(diào)用。如果參數(shù)是復(fù)雜的,則宏調(diào)用相應(yīng)的復(fù)變函數(shù)(cacosf
,cacos
,cacosl
)。
arg | - | 浮點(diǎn)值 |
---|
如果沒有錯誤發(fā)生,arg
則范圍為0 的(arccos(arg))的反余弦值為0; π,返回。
如果發(fā)生域錯誤,則返回實現(xiàn)定義的值(NaN,如果支持)。
如果由于下溢而發(fā)生范圍錯誤,則返回正確的結(jié)果(舍入后)。
按照math_errhandling中的指定報告錯誤。
如果arg
超出范圍,則會發(fā)生域錯誤[-1.0; 1.0]
。
如果實現(xiàn)支持IEEE浮點(diǎn)運(yùn)算(IEC 60559),
如果參數(shù)為+1,+0
則返回該值。
如果| arg | > 1,發(fā)生域錯誤并返回NaN。
如果參數(shù)是NaN,則返回NaN
#include <stdio.h>#include <math.h>#include <errno.h>#include <fenv.h>#include <string.h> #pragma STDC FENV_ACCESS ON int main(void){ printf("acos(-1) = %f\n", acos(-1)); printf("acos(0.0) = %f 2*acos(0.0) = %f\n", acos(0), 2*acos(0)); printf("acos(0.5) = %f 3*acos(0.5) = %f\n", acos(0.5), 3*acos(0.5)); printf("acos(1) = %f\n", acos(1)); // error handling errno = 0; feclearexcept(FE_ALL_EXCEPT); printf("acos(1.1) = %f\n", acos(1.1)); if(errno == EDOM) perror(" errno == EDOM"); if(fetestexcept(FE_INVALID)) puts(" FE_INVALID raised");}
可能的輸出:
acos(-1) = 3.141593acos(0.0) = 1.570796 2*acos(0.0) = 3.141593acos(0.5) = 1.047198 3*acos(0.5) = 3.141593acos(1) = 0.000000acos(1.1) = nan errno == EDOM: Numerical argument out of domain FE_INVALID raised
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.12.4.1阿科斯函數(shù)(p:238)
7.25類型通用數(shù)學(xué)<tgmath.h>(p:373-375)
F.10.1.1 acos功能(p:518)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.12.4.1 acos功能(p:218)
7.22類型通用數(shù)學(xué)<tgmath.h>(p:335-337)
F.9.1.1 acos功能(p:455)
C89 / C90標(biāo)準(zhǔn)(ISO / IEC 9899:1990):
4.5.2.1 acos函數(shù)