PatchworkOS
Loading...
Searching...
No Matches
sin.c
Go to the documentation of this file.
1#include <errno.h>
2#include <math.h>
3#include <stdbool.h>
4
5// https://cppreference.com/w/c/numeric/math/sin.html
6double sin(double x)
7{
8 if (x == 0.0 || x == -0.0)
9 {
10 return 0.0;
11 }
12
13 if (isinf(x))
14 {
15 errno = EDOM;
16 return NAN;
17 }
18
19 if (isnan(x))
20 {
21 return NAN;
22 }
23
24 double result;
25 asm volatile("fsin" : "=t"(result) : "0"(x));
26 return result;
27}
#define EDOM
Math argument out of domain of func.
Definition errno.h:197
#define errno
Error number variable.
Definition errno.h:27
#define isinf(x)
Definition math.h:37
#define isnan(x)
Definition math.h:39
#define NAN
Definition math.h:20
int64_t x
Definition main.c:152
double sin(double x)
Definition sin.c:6