9front - general discussion about 9front
 help / color / mirror / Atom feed
From: "Iruatã Souza" <iru.muzgo@gmail.com>
To: 9front@9front.org
Subject: [9front] [patch] add log2 to ape
Date: Sun, 6 Dec 2020 17:56:59 +0100	[thread overview]
Message-ID: <3e3488b7-ef5f-3fc2-bff9-611a96bf86e6@gmail.com> (raw)

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;
+}

             reply	other threads:[~2020-12-06 16:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-06 16:56 Iruatã Souza [this message]
2020-12-06 18:49 ` ori
2020-12-07 10:16   ` Iruatã Souza
2020-12-07 11:34     ` Iruatã Souza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e3488b7-ef5f-3fc2-bff9-611a96bf86e6@gmail.com \
    --to=iru.muzgo@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).