sincosd
Compute the sine and cosine of the input angle at the same time.
Interface Definition
C interface:
void sincosdf(float x, float* sinx, float* cosx);
void sincosd(double x, double* sinx, double* cosx);
void sincosdl(long double x, long double* sinx, long double* cosx);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value representing an angle. |
Input |
sinx |
|
Value to which sinx points. If the pointer is null, an undefined behavior occurs, and the interface does not verify the output pointer. |
Output |
cosx |
|
Value to which cosx points. If the pointer is null, an undefined behavior occurs, and the interface does not verify the output pointer. |
Output |
Return Value
- The sine sinx and cosine cosx of angle x are returned. sinx ∈ [-1, +1]; cosx ∈ [-1, +1]
- If the input is +0, the sine is +0 and the cosine is +1.
- If the input is -0, the sine is -0 and the cosine is +1.
- If the input is ±∞, the sine and cosine are both NaN.
- If the input is NaN, the sine and cosine are both NaN.
Dependencies
#include "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // typical usage double x1 = INFINITY, sinx1, cosx1; double x2 = 2.0, sinx2, cosx2; double x3 = -2.5, sinx3, cosx3; double x4 = NAN, sinx4, cosx4; double x5 = 0.0, sinx5, cosx5; sincosd(x1, &sinx1, &cosx1); sincosd(x2, &sinx2, &cosx2); sincosd(x3, &sinx3, &cosx3); sincosd(x4, &sinx4, &cosx4); sincosd(x5, &sinx5, &cosx5); // print result printf("/*\n"); printf(" * sincosd(%.2f), sinval = %.6f cosval= %.6f\n", x1, sinx1, cosx1); printf(" * sincosd(%.2f), sinval = %.6f cosval= %.6f\n", x2, sinx2, cosx2); printf(" * sincosd(%.2f), sinval = %.6f cosval= %.6f\n", x3, sinx3, cosx3); printf(" * sincosd(%.2f), sinval = %.6f cosval= %.6f\n", x4, sinx4, cosx4); printf(" * sincosd(%.2f), sinval = %.6f cosval= %.6f\n", x5, sinx5, cosx5); /* * sincosd(inf), sinval = nan cosval= nan * sincosd(2.00), sinval = 0.034899 cosval= 0.999391 * sincosd(-2.50), sinval = -0.043619 cosval= 0.999048 * sincosd(nan), sinval = nan cosval= nan * sincosd(0.00), sinval = 0.000000 cosval= 1.000000 |
Parent topic: Trigonometric Functions