次の方法で共有


acos、acosf、acosl

アークコサインを計算します。

double acos( 
   double x 
);
float acos(
   float x 
);   // C++ only
long double acos(
   long double x
);   // C++ only
float acosf(
   float x 
);
long double acosl(
   long double x
);

パラメーター

  • x
    アークコサイン (逆コサイン) を計算する –1 ~ 1 の間の値。

戻り値

acos 関数は、0 ~ π ラジアンの範囲で x のアークコサインを返します。

既定では、x が –1 未満または 1 よりも大きい場合、acos は不定値を返します。

入力

SEH 例外

Matherr 例外

± ∞

INVALID

_DOMAIN

± QNAN、IND

なし

_DOMAIN

|x| > 1

INVALID

_DOMAIN

解説

C++ ではオーバーロードが可能であるため、float 型および long double 型を受け取って返す acos のオーバーロードを呼び出すことができます。 C プログラムでは、acos は常に double を受け取って返します。

必要条件

ルーチン

必須ヘッダー

省略可能なヘッダー

acos, acosf, acosl

<math.h>

<errno.h>

使用例

このプログラムは、-1 ~ 1 の範囲の値の入力を求めます。 入力値がこの範囲外の場合、_DOMAIN エラー メッセージを生成します。 有効な値が入力された場合、プログラムはその値のアークサインとアークコサインを出力します。

// crt_asincos.c
// arguments: 0

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main( int ac, char* av[] )
{
    double  x,
            y;
    errno_t err; 

    // argument checking
    if (ac != 2)
    {
        fprintf_s( stderr, "Usage: %s <number between -1 and 1>\n",
                   av[0]);
        return 1;
    }

    // Convert argument into a double value
    if ((err = sscanf_s( av[1], "%lf", &x )) != 1)
    {
        fprintf_s( stderr, "Error converting argument into ",
                   "double value.\n");
        return 1;
    }

    // Arcsine of X
    y = asin( x );
    printf_s( "Arcsine of %f = %f\n", x, y );

    // Arccosine of X
    y = acos( x );
    printf_s( "Arccosine of %f = %f\n", x, y );
}
  

同等の .NET Framework 関数

System::Math::Acos

参照

関連項目

浮動小数点サポート

asin、asinf、asinl

atan、atanf、atanl、atan2、atan2f、atan2l

cos、cosf、cosl、cosh、coshf、coshl

_matherr

sin、sinf、sinl、sinh、sinhf、sinhl

tan、tanf、tanl、tanh、tanhf、tanhl