From be3809866ce89d2dcac0b02f2ec7b49b5393cb56 Mon Sep 17 00:00:00 2001 From: aiju Date: Thu, 24 May 2018 13:40:44 +0100 Subject: [PATCH] ape: floating point improvements (thanks spew) --- 386/include/ape/math.h | 2 ++ 68020/include/ape/math.h | 2 ++ amd64/include/ape/math.h | 1 + arm/include/ape/math.h | 2 ++ mips/include/ape/math.h | 2 ++ power/include/ape/math.h | 2 ++ sparc/include/ape/math.h | 2 ++ sparc64/include/ape/math.h | 2 ++ sys/src/ape/lib/ap/math/fmin.c | 11 +++++++++++ sys/src/ape/lib/ap/math/mkfile | 1 + 10 files changed, 27 insertions(+) create mode 100644 sys/src/ape/lib/ap/math/fmin.c diff --git a/386/include/ape/math.h b/386/include/ape/math.h index 41e1024f5..a9cd9dfa5 100644 --- a/386/include/ape/math.h +++ b/386/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/68020/include/ape/math.h b/68020/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/68020/include/ape/math.h +++ b/68020/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/amd64/include/ape/math.h b/amd64/include/ape/math.h index a880a01f8..3bd3daade 100644 --- a/amd64/include/ape/math.h +++ b/amd64/include/ape/math.h @@ -37,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/arm/include/ape/math.h b/arm/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/arm/include/ape/math.h +++ b/arm/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/mips/include/ape/math.h b/mips/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/mips/include/ape/math.h +++ b/mips/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/power/include/ape/math.h b/power/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/power/include/ape/math.h +++ b/power/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/sparc/include/ape/math.h b/sparc/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/sparc/include/ape/math.h +++ b/sparc/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/sparc64/include/ape/math.h b/sparc64/include/ape/math.h index 5fa374801..3d2276bd6 100644 --- a/sparc64/include/ape/math.h +++ b/sparc64/include/ape/math.h @@ -15,6 +15,7 @@ extern double asin(double); extern double atan(double); extern double atan2(double, double); extern double cos(double); +extern double hypot(double, double); extern double sin(double); extern double tan(double); extern double cosh(double); @@ -36,6 +37,7 @@ extern double NaN(void); extern int isNaN(double); extern double Inf(int); extern int isInf(double, int); +extern double fmin(double, double); #ifdef _RESEARCH_SOURCE /* does >> treat left operand as unsigned ? */ diff --git a/sys/src/ape/lib/ap/math/fmin.c b/sys/src/ape/lib/ap/math/fmin.c new file mode 100644 index 000000000..5ab8bc2f1 --- /dev/null +++ b/sys/src/ape/lib/ap/math/fmin.c @@ -0,0 +1,11 @@ +#include + +double +fmin(double a, double b) +{ + if(isNaN(a)) + return b; + if(isNaN(b)) + return a; + return a < b ? a : b; +} diff --git a/sys/src/ape/lib/ap/math/mkfile b/sys/src/ape/lib/ap/math/mkfile index 5e2d7483f..43ba976fd 100644 --- a/sys/src/ape/lib/ap/math/mkfile +++ b/sys/src/ape/lib/ap/math/mkfile @@ -10,6 +10,7 @@ OFILES=\ fabs.$O\ floor.$O\ fmod.$O\ + fmin.$O\ gamma.$O\ hypot.$O\ j0.$O\ -- 2.44.0