tan, atan

This commit is contained in:
K. Lange 2018-09-21 21:34:53 +09:00
parent 379b262d64
commit 8bdca7fdda
2 changed files with 18 additions and 10 deletions

View File

@ -14,11 +14,6 @@ double asin(double x) {
return 0.0;
}
double atan(double x) {
BAD;
return 0.0;
}
double ceil(double x) {
BAD;
return 0.0; /* extract and convert? */
@ -58,11 +53,6 @@ double sinh(double x) {
return 0.0;
}
double tan(double x) {
BAD;
return 0.0;
}
double tanh(double x) {
BAD;
return 0.0;

View File

@ -444,6 +444,20 @@ double cos(double x) {
return sin(x + 3.141592654 / 2.0);
}
double tan(double x) {
float out;
float one;
float _x = x;
asm volatile (
"fld %2\n"
"fptan\n"
"fstp %1\n"
"fstp %0\n"
: "=m"(out), "=m"(one) : "m"(_x)
);
return out;
}
double atan2(double y, double x) {
float out;
float _x = x;
@ -458,6 +472,10 @@ double atan2(double y, double x) {
return out;
}
double atan(double x) {
return atan2(x,1.0);
}
double hypot(double x, double y) {
return sqrt(x * x + y * y);
}