summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2018-05-24 13:40:44 +0100
committeraiju <devnull@localhost>2018-05-24 13:40:44 +0100
commitbe3809866ce89d2dcac0b02f2ec7b49b5393cb56 (patch)
tree1c1b211ddbd23367e2c3c692804f814fbe3fba8a /sys/src/ape/lib/ap
parent930efe67e81635e632f1e6f93e1c56499c79a55f (diff)
ape: floating point improvements (thanks spew)
Diffstat (limited to 'sys/src/ape/lib/ap')
-rw-r--r--sys/src/ape/lib/ap/math/fmin.c11
-rw-r--r--sys/src/ape/lib/ap/math/mkfile1
2 files changed, 12 insertions, 0 deletions
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 <math.h>
+
+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\