9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [patch] add log2 to ape
@ 2020-12-06 16:56 Iruatã Souza
  2020-12-06 18:49 ` ori
  0 siblings, 1 reply; 4+ messages in thread
From: Iruatã Souza @ 2020-12-06 16:56 UTC (permalink / raw)
  To: 9front

Hi,

This adds log2 to APE. It is defined in posix and at least Lua expects it.

diff -r 543ad076adbc sys/src/ape/lib/ap/math/log.c
--- a/sys/src/ape/lib/ap/math/log.c	Sun Dec 06 15:08:23 2020 +0100
+++ b/sys/src/ape/lib/ap/math/log.c	Sun Dec 06 17:45:18 2020 +0100
@@ -10,7 +10,7 @@
 #include <math.h>
 #include <errno.h>

-#define	log2    0.693147180559945309e0
+#define	_log2   0.693147180559945309e0
 #define	ln10o1  .4342944819032518276511
 #define	sqrto2  0.707106781186547524e0
 #define	p0      -.240139179559210510e2
@@ -46,7 +46,7 @@

 	temp = ((p3*zsq + p2)*zsq + p1)*zsq + p0;
 	temp = temp/(((zsq + q2)*zsq + q1)*zsq + q0);
-	temp = temp*z + exp*log2;
+	temp = temp*z + exp*_log2;
 	return temp;
 }

@@ -60,3 +60,9 @@
 	}
 	return log(arg) * ln10o1;
 }
+
+double
+log2(double arg)
+{
+	return log(x)/_log2;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-07 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 16:56 [9front] [patch] add log2 to ape Iruatã Souza
2020-12-06 18:49 ` ori
2020-12-07 10:16   ` Iruatã Souza
2020-12-07 11:34     ` Iruatã Souza

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).