English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and examples of the C library function asin()

C Standard Library <math.h>

The asin() function returns the arc sine value expressed in radians.

The asin() function takes a single parameter (1≥x≥-1),and returns the arc sine value in radians.

The asin() function is included in the <math.h> header file.

asin() prototype

double asin(double x);

要查找类型为int,float或long double的反正弦,可以使用强制转换运算符将类型显式转换为double。

 To find the arcsine of type int, float, or long double, you can use the explicit type conversion operator to convert the type to double.
 int x = 0;
 double result;

result = asin(double(x));99Additionally, C

float asinf(float x);
long double asinl(long double x);

asin() parameter

The asin() function uses-1,+1] range.1to-1between

ParameterDescription
double value

required. A single parameter between- 1and+1and

asin() return value

The asin() function returns a double-precision value between-π/ 2,+π/ 2] returns this value in radians range. If the parameter passed to the asin() function is less than-1or greater1If the parameter of this function is less than or greater than the range, then the function returns NaN (Not a Number).

Parameter (x)Return value
x = [-1, +1][-π/2, +π/2] radians
 -1 > x or x > 1NaN (Not a Number)

Example1: asin() function with different parameters

#include <stdio.h>
#include <math.h>
int main()
{
    // PI constant
    const double PI =  3.1415926;
    double x, result;
    x =  -0.5;
    result = asin(x);
    printf("Inverse of sin(%.2f) arcsine value = %.2lf radians\n", x, result);
    //Convert radians to degrees
    result = asin(x)*180/PI;
    printf("Inverse of sin(%.2f) arcsine value = %.2lf in degrees\n", x, result);
    //Parameter is out of range
    x = 1.2;
    result = asin(x);
    printf("Inverse of sin(%.2f) arcsine value = %.2lf, x, result);
    return 0;
}

Output Result

sin(-0.50) arcsine value = -0.52 Radians
sin(-0.50) arcsine value = -30.00 degrees
sin(1.20) arcsine value = nan

Example2: asinf() and asinl() functions

#include <stdio.h>
#include <math.h>
int main()
{
    float fx, fasinx;
    long double lx, ldasinx;
    // floating-point arc sine
    fx = -0.505405;
    fasinx = asinf(fx);
    // arcsine of long double type
    lx = -0.50540593;
    ldasinx = asinf(lx);
    printf("asinf(x) = %f radians\n", fasinx);
    printf("asinl(x) Arcsine Value = %Lf Radians", ldasinx);
    return 0;
}

Output Result

asinf(x) Arcsine Value = -0.529851 Radians
asinl(x) Arcsine Value = -0.529852 Radians

C Standard Library <math.h>