Freigeben über


acos, acosf, acosl

Berechnet den Arkuskosinus.

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
);

Parameter

  • x
    Wert zwischen – 1 und 1, für den der Arkuskosinus berechnet werden soll (der umgekehrte Kosinus).

Rückgabewert

Die acos-Funktion gibt den Arkuskosinus von x im Bogenmaß im Bereich 0 bis π zurück.

Wenn x kleiner als – 1 oder größer als 1 ist, gibt acos standardmäßig einen unbestimmten Wert zurück.

Eingabe

SEH-Ausnahme

Matherr-Ausnahme

± ∞

INVALID

_DOMAIN

± QNAN,IND

Keine

_DOMAIN

|x|>1

INVALID

_DOMAIN

Hinweise

Da C++ das Überladen zulässt, können Sie Überladungen von acos aufrufen, die float und long double-Typen verwenden und zurückgeben. In einem C-Programm verwendet acos immer double und gibt diesen Wert zurück.

Anforderungen

Routine

Erforderlicher Header

Optionale Header

acos, acosf, acosl

<math.h>

<errno.h>

Beispiel

Dieses Programm fordert zur Eingabe eines Werts im – 1 bis 1 auf. Eingabewerte außerhalb dieses Bereichs erzeugen _DOMAIN-Fehlermeldungen. Wenn ein gültiger Wert eingegeben wird, gibt das Programm den Arkussinus und den Arkuskosinus dieses Werts aus.

// 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-Entsprechung

System::Math::Acos

Siehe auch

Referenz

Gleitkommaunterstützung

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