sincosd
Compute the sine and cosine of the input degree at the same time.
Interface Definition
C interface:
void sincosdf(float x, float* sinx, float* cosx);
void sincosd(double x, double* sinx, double* cosx);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of a degree angle. |
Input |
sinx |
|
Output pointer sinx. If the pointer is null, an undefined behavior occurs, and the interface does not verify the output pointer. |
Output |
cosx |
|
Output pointer cosx. 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 degree 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.
Dependency
#include "km.h"
Example
C interface:
// 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: Function Syntax