[Nickle] nickle: Branch 'master' - 6 commits

Keith Packard keithp at keithp.com
Fri Apr 17 13:00:47 PDT 2020


 configure.ac         |    4 ++--
 debian/changelog     |    7 +++++++
 debian/gbp.conf      |    7 +++++++
 debian/source/format |    2 +-
 file.c               |    2 +-
 math.5c              |    8 +++++++-
 test/math.5c         |    7 +++++++
 7 files changed, 32 insertions(+), 5 deletions(-)

New commits:
commit 021464ab0ce541960cb1e49f1c7124548df7eb8f
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 10:00:28 2020 -0700

    Bump to version 2.86
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 2557b19..53b5c5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,8 +6,8 @@ dnl for licensing information.
 
 AC_PREREQ([2.69])
 
-AC_INIT([nickle],[2.85],[http://nickle.org],[nickle])
-RELEASE_DATE="2019-07-31"
+AC_INIT([nickle],[2.86],[http://nickle.org],[nickle])
+RELEASE_DATE="2020-04-17"
 AC_CONFIG_SRCDIR([nickle.h])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR(.)
diff --git a/debian/changelog b/debian/changelog
index a605925..1d61eaa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+nickle (2.86) unstable; urgency=medium
+
+  * Fix exp() of small values. They were rounding to zero
+  * Stop depending on 'common' semantics in file.c. Closes: #957611.
+
+ -- Keith Packard <keithp at keithp.com>  Fri, 17 Apr 2020 09:56:33 -0700
+
 nickle (2.85-1) unstable; urgency=medium
 
   * Fix crash when File::string_string is passed an empty buffer
commit 05ced9f8730876b0c761499ec5beead7fb7c8da1
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 12:28:37 2020 -0700

    fix source format

diff --git a/debian/source/format b/debian/source/format
index 163aaf8..89ae9db 100644
--- a/debian/source/format
+++ b/debian/source/format
@@ -1 +1 @@
-3.0 (quilt)
+3.0 (native)
commit 2064f8bcf82cac1216d0695333c2cd5fed13bf29
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 12:22:18 2020 -0700

    Add gbp.conf

diff --git a/debian/gbp.conf b/debian/gbp.conf
new file mode 100644
index 0000000..78e394e
--- /dev/null
+++ b/debian/gbp.conf
@@ -0,0 +1,7 @@
+[DEFAULT]
+debian-branch = master
+pristine-tar = False
+upstream-branch = master
+
+[buildpackage]
+upstream-tree = BRANCH
commit 1614e7ed0c825b523f950fe412c68ba22762694b
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 09:55:21 2020 -0700

    Add test for exp() of very small values.
    
    This was failing before the scale adjustment patch went in.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/test/math.5c b/test/math.5c
index 0a9d7a1..55c38d1 100644
--- a/test/math.5c
+++ b/test/math.5c
@@ -176,6 +176,13 @@ void check_exp()
 				errors++;
 			}
 		}
+		for (int p = 0; p < prec // 3; p++) {
+		    real x = imprecise(2 ** -p, prec);
+		    if (exp(x) - 1 == 0) {
+			printf("exp(x): prec %d is one for p %d x %.-g\n", prec, p, x);
+			errors++;
+		    }
+		}
 		for (real x = imprecise(0.001, prec); x < 20; x *= 1.5) {
 			for (real y = imprecise(0.001, prec); y < 20; y *= 1.5) {
 
commit cde5d924b486a95e14082fee5584a00ef3d80d46
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 09:51:55 2020 -0700

    Declare common variables as extern in file.c
    
    Don't depend on C 'common' semantics for stdinOwned and stdinPolling.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/file.c b/file.c
index 453afc0..bb933f5 100644
--- a/file.c
+++ b/file.c
@@ -29,7 +29,7 @@
 
 ReferencePtr	fileBlockedReference;
 Value		fileBlocked;
-Bool		stdinOwned, stdinPolling;
+extern Bool	stdinOwned, stdinPolling;
 #ifdef NO_PIPE_SIGIO
 Bool		anyPipeReadBlocked;
 #endif
commit f4f6551d8890ee7bc6e3d3da54cdd21e3cbdd556
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 17 09:50:24 2020 -0700

    Don't scale values *up* when adjusting exp value
    
    Make sure the intermediate value isn't getting scaled *up*
    when adjusting values towards zero to get exp to converge faster.
    This makes sure exp of small values is as accurate as desired.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/math.5c b/math.5c
index 7ba9590..77b6608 100644
--- a/math.5c
+++ b/math.5c
@@ -218,18 +218,21 @@ extend namespace Math {
 	 * makes the expansion step more expensive.
 	 */
 	int prec = precision (v);
+	int expo = exponent (v);
 	int scale;
 	if (prec > 50)
 	    scale = 27;
 	else
 	    scale = 12;
+	if (expo + scale < 0)
+	    scale = -expo;
+	expo += scale;
 	int div = (1 << scale);
 
 	int iter = prec + 1;
 	int iprec = prec + iter;
 
 	real mant = imprecise (mantissa(v), iprec) / div;
-	int expo = exponent(v) + scale;
 
 	real e = imprecise (0, iprec);
 	real num = imprecise (1, iprec);
@@ -968,6 +971,9 @@ extend namespace Math {
 	 */
     {
 	real    result;
+	if (a == 0)
+	    return 0;
+
 	if (is_int (b))
 	{
 	    if (!is_int (a) && is_rational (a))


More information about the Nickle mailing list