PatchworkOS  19e446b
A non-POSIX operating system.
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#include <sys/defs.h>
5
6// https://cppreference.com/w/c/numeric/math/sin.html
7double sin(double x)
8{
9 if (x == 0.0 || x == -0.0)
10 {
11 return 0.0;
12 }
13
14 if (isinf(x))
15 {
16 errno = EDOM;
17 return NAN;
18 }
19
20 if (isnan(x))
21 {
22 return NAN;
23 }
24
25 double result;
26 ASM("fsin" : "=t"(result) : "0"(x));
27 return result;
28}
int64_t x
Definition main.c:152
#define EDOM
Math argument out of domain of func.
Definition errno.h:197
#define errno
Error number variable.
Definition errno.h:27
#define ASM(...)
Inline assembly macro.
Definition defs.h:160
#define isinf(x)
Definition math.h:37
#define isnan(x)
Definition math.h:39
#define NAN
Definition math.h:20
double sin(double x)
Definition sin.c:7