From 74f87fd111904e5156727c72590d6fc4f67e8366 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 3 Mar 2017 09:17:51 -0800 Subject: logb now works correctly on large integers * admin/merge-gnulib (GNULIB_MODULES): Add count-leading-zeros. * etc/NEWS: Document the change. * lib/count-leading-zeros.c, lib/count-leading-zeros.h: * m4/count-leading-zeros.m4: New files, copied from Gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * src/floatfns.c: Include count-leading-zeros.h. (Flogb): Do not convert fixnum to float before taking the log, as the rounding error can cause the answer to be off by 1. * src/lisp.h (EMACS_UINT_WIDTH): New constant. * test/src/floatfns-tests.el (logb-extreme-fixnum): New test. --- m4/count-leading-zeros.m4 | 12 ++++++++++++ m4/gnulib-comp.m4 | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 m4/count-leading-zeros.m4 (limited to 'm4') diff --git a/m4/count-leading-zeros.m4 b/m4/count-leading-zeros.m4 new file mode 100644 index 00000000000..b6e97cf13f8 --- /dev/null +++ b/m4/count-leading-zeros.m4 @@ -0,0 +1,12 @@ +# count-leading-zeros.m4 serial 2 +dnl Copyright (C) 2012-2017 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_COUNT_LEADING_ZEROS], +[ + dnl We don't need (and can't compile) count_leading_zeros_ll + dnl unless the type 'unsigned long long int' exists. + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) +]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 14af9fbd6bf..a3e30fd736e 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -54,6 +54,7 @@ AC_DEFUN([gl_EARLY], # Code from module careadlinkat: # Code from module clock-time: # Code from module close-stream: + # Code from module count-leading-zeros: # Code from module count-one-bits: # Code from module count-trailing-zeros: # Code from module crypto/md5: @@ -190,6 +191,7 @@ AC_DEFUN([gl_INIT], gl_CLOCK_TIME gl_CLOSE_STREAM gl_MODULE_INDICATOR([close-stream]) + gl_COUNT_LEADING_ZEROS gl_COUNT_ONE_BITS gl_COUNT_TRAILING_ZEROS gl_MD5 @@ -871,6 +873,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/careadlinkat.h lib/close-stream.c lib/close-stream.h + lib/count-leading-zeros.c + lib/count-leading-zeros.h lib/count-one-bits.c lib/count-one-bits.h lib/count-trailing-zeros.c @@ -1000,6 +1004,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/c-strtod.m4 m4/clock_time.m4 m4/close-stream.m4 + m4/count-leading-zeros.m4 m4/count-one-bits.m4 m4/count-trailing-zeros.m4 m4/dirent_h.m4 -- cgit v1.2.1