C asin() Function

Definition
In C, asin() returns the angle whose sine is x. The angle is in radians, from -π/2 to π/2. asin(0) is 0, and asin(1) is π/2.
You pass one double. It must be from -1 to 1. The result is a double in radians, not degrees. Include <math.h>.
Syntax
Pass a sine from -1 to 1. Start with this call.
| Call | What it does |
|---|
asin(1.0) | Returns π/2, the angle whose sine is 1. |
Include <math.h>. On GCC, link with -lm. The result is radians.
Library declarations
double asin(double x);
float asinf(float x);
long double asinl(long double x);
Parameters
| Parameter | Description |
|---|
| x | Required. A sine from -1 to 1. |
Return Value
| Return Value | Description |
|---|
| Radians | The angle from -π/2 to π/2 whose sine is x. |
| NaN | Returned when x is outside -1 to 1. |
C Examples
Example 1 — Common asin Values
Print radians for a few sine inputs in the valid domain.
#include <math.h>
#include <stdio.h>
int main(void) {
printf("asin(0) = %.4f\n", asin(0.0));
printf("asin(0.5) = %.4f\n", asin(0.5));
printf("asin(1) = %.4f\n", asin(1.0));
printf("asin(-0.5) = %.4f\n", asin(-0.5));
return 0;
}
asin(0) = 0.0000
asin(0.5) = 0.5236
asin(1) = 1.5708
asin(-0.5) = -0.5236
How It Works
- Include math.h. Declares
asin; link with -lm on GCC. - Zero and half.
asin(0) is 0; asin(0.5) is π/6. - Endpoint.
asin(1) is π/2 (90°). - Odd function. Negative inputs give negative angles:
asin(-0.5) = -asin(0.5).
Example 2 — Convert Radians to Degrees
Multiply by 180 / π when you want a degree reading.
#include <math.h>
#include <stdio.h>
int main(void) {
double x = 0.5;
double rad = asin(x);
double pi = acos(-1.0);
double deg = rad * 180.0 / pi;
printf("asin(%.1f) = %.4f rad\n", x, rad);
printf(" = %.2f deg\n", deg);
return 0;
}
asin(0.5) = 0.5236 rad
= 30.00 degHow It Works
- Get radians first.
asin(0.5) ≈ 0.5236. - Get π portably.
acos(-1.0) equals π without needing M_PI. - Scale to degrees. Multiply by
180.0 / pi → 30. - Keep rad for math. Pass radians into
sin/cos; use degrees only for display.
Example 3 — Check with sin
Round-trip a value: sin(asin(x)) should recover x on the valid domain.
#include <math.h>
#include <stdio.h>
int main(void) {
double x = 0.75;
double rad = asin(x);
printf("asin(%.2f) = %.5f\n", x, rad);
printf("sin(rad) = %.5f\n", sin(rad));
return 0;
}
asin(0.75) = 0.84806
sin(rad) = 0.75000
How It Works
- Start with a valid sine.
0.75 is in [-1, 1]. - Invert with asin. You get an angle in
[-π/2, π/2]. - Apply sin.
sin(rad) returns to 0.75. - Inverse pair. Use this pattern to verify your understanding of
asin and sin.
Frequently Asked Questions
asin() returns the angle, in radians, whose sine is x. asin(0) is 0 and asin(1) is π/2.
x is required. It is a double from -1 to 1.
A double in radians, from -π/2 to π/2. If x is outside -1 to 1, the result is NaN.
Include <math.h>. On GCC, link with -lm.
No. The result is radians. Multiply by 180/π when you want degrees.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful