guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-14-72-gdc


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-14-72-gdc78bee
Date: Thu, 20 Jan 2011 22:40:49 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=dc78bee588718ce4df252e5d1773b9d895c6f43f

The branch, master has been updated
       via  dc78bee588718ce4df252e5d1773b9d895c6f43f (commit)
       via  7cd99cbad6e5e9186cf1a82038a4f79b3ada4e72 (commit)
       via  01c7284ae5c30191e3e21afe432f9315520b412f (commit)
      from  b1846b7fb31de1bbe126322688ac109fd86a924e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dc78bee588718ce4df252e5d1773b9d895c6f43f
Author: Andy Wingo <address@hidden>
Date:   Thu Jan 20 23:44:40 2011 +0100

    add NEWS for expt change
    
    * NEWS: Update for Mark's expt patch.

commit 7cd99cbad6e5e9186cf1a82038a4f79b3ada4e72
Author: Andy Wingo <address@hidden>
Date:   Thu Jan 20 23:39:56 2011 +0100

    update NEWS for 1.9.14
    
    * NEWS: Fold 1.9.14 entries into main text.

commit 01c7284ae5c30191e3e21afe432f9315520b412f
Author: Mark H Weaver <address@hidden>
Date:   Thu Nov 4 22:10:02 2010 -0400

    Fix bugs in expt and integer-expt
    
    * libguile/numbers.c (scm_expt): Fix bug that caused expt to throw an
      exception whenever the base was exact and the exponent was an
      inexact integer, e.g. (expt 5 6.0).
    
      (scm_expt): Fix bug that caused expt to introduce spurious imaginary
      parts in the result when the base was an inexact negative real and
      the exponent was an integer, e.g. (expt -1.0 2)
    
      (scm_integer_expt, scm_expt): Change behavior of (integer-expt 0 -1),
      and therefore also (expt 0 -1), to return NaN, per R6RS (actually,
      R6RS says we should throw an exception or return an "unspecified
      number object", but for now we use NaN).  Formerly we returned 0, per
      R5RS. R5RS claims that 0^x=0 for all non-zero x, but that's
      mathematically incorrect, and probably an oversight.
    
      (scm_integer_expt): Consistently throw a wrong-argument-type exception
      when the exponent is inexact.  Formerly, it didn't always check this
      if the base was 0, 1, or -1.
    
    * test-suite/tests/numbers.test ("integer-expt", "expt"): Add tests.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                          |  175 +++++++++++++++-------------------------
 libguile/numbers.c            |   41 +++++++++-
 test-suite/tests/numbers.test |   48 ++++++++++-
 3 files changed, 145 insertions(+), 119 deletions(-)

diff --git a/NEWS b/NEWS
index 045d1ef..bf6b4f2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,5 @@
 Guile NEWS --- history of user-visible changes.
-Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 See the end for copying conditions.
 
 Please send Guile bug reports to address@hidden
@@ -8,114 +8,15 @@ Please send Guile bug reports to address@hidden
 Note: During the 1.9 series, we will keep an incremental NEWS for the
 latest prerelease, and a full NEWS corresponding to 1.8 -> 2.0.
 
-Changes in 1.9.14 (since the 1.9.13 prerelease):
+Changes in 1.9.15 (since the 1.9.14 prerelease):
 
-** New module: `(ice-9 futures)'.
-    
-See "Futures" in the manual, for more information.
-
-** Add bindings to GNU `sched_setaffinity' and `sched_getaffinity'.
-    
-See "Processes" in the manual, for more information.
-
-** New module `(srfi srfi-38)', External Representation for Data With Shared 
Structure
-
-See "SRFI-38" in the manual, for more information.  Thanks to Andreas
-Rottmann.
-
-** New module: `(web uri)', URI data type, parser, and unparser
-** New module: `(web http)', HTTP header parsers and unparsers
-** New module: `(web request)', HTTP request data type, reader, and writer
-** New module: `(web response)', HTTP response data type, reader, and writer
-** New module: `(web server)', Generic HTTP server
-** New module: `(ice-9 poll)', a poll wrapper
-** New module: `(web server http)', HTTP-over-TCP web server implementation
-
-See "Web" in the manual, for more information, but as a taste of things,
-try the following command line:
-
-  meta/guile examples/web/debug-sxml.scm
-
-Then visit http://localhost:8080/ in your web browser.  Let us know how
-it goes!
-
-** Better Emacs Lisp implementation
-
-Brian Templeton's Summer-of-Code work was finally merged in, which
-should improve the state of Guile's Elisp support.  There is still some
-work to do, so patches are welcome!
-
-** R6RS fixes
-
-There were many fixes and enhancements to the R6RS support.  Thanks to
-Julian Graham, Andreas Rottmann, and Göran Weinholt.
-
-** Expression-oriented readline history
-    
-Guile's readline history now tries to operate on expressions instead of
-input lines.  Let us know what you think!
-
-** Better syntax errors
-
-The Scheme expander, Ecmascript compiler, and other language
-implementations now produce more useful syntax errors.  The default
-error handlers print them out more nicely now.
-
-** Lots of documentation updates
-
-In particular, the documentation for GOOPS and regular expressions has
-seen some work.  Unfortunately the code has come too fast and furious
-for full documentary folios, so some of the new modules are still
-undocumented.
-
-** Better pretty-printing
-
-Indentation recognizes more special forms, like `syntax-case', and read
-macros like `quote' are printed better.
+** `expt' and `integer-expt' changes when the base is 0
 
-** Multicast socket options
-
-Support was added for the IP_MULTICAST_TTL and IP_MULTICAST_IF socket
-options.  See "Network Sockets and Communication" in the manual, for
-more information.
-
-** Deprecate `cuserid'
-    
-`cuserid' has been deprecated, as it only returns 8 bytes of a user's
-login.  Use `(passwd:name (getpwuid (geteuid)))' instead.
-    
-** New procedure `reload-module', and `,reload' REPL command
-    
-See "Module System Reflection" and "Module Commands" in the manual, for
-more information.
-
-** New `,in' REPL command
-
-See "Module Commands" in the manual, for more information.
-
-** Allow user-defined REPL meta-commands
-    
-This feature is not documented yet.  See `define-meta-command' in
-`(system repl command)'.
-
-** Add support for unbound fluids
-    
-See `make-unbound-fluid', `fluid-unset!', and `fluid-bound?' in the
-manual.
-
-** Add `variable-unset!'
-    
-See "Variables" in the manual, for more details.
-
-** New procedures: `compose', `negate', and `const'
-
-See "Higher-Order Functions" in the manual, for more information.
-
-** Command line additions
-
-The guile binary now supports a new switch "-x", which can be used to
-extend the list of filename extensions tried when loading files
-(%load-extensions).
+While `(expt 0 0)' is still 1, `(expt 0 N)' for N > 0 is now 0, and
+`(expt 0 N)' for N < 0 is now a NaN value, and likewise for
+integer-expt.  This is more correct, and conforming to R6RS, but seems
+to be incompatible with R5RS, which would always return 0 for all values
+of N.
 
 ** And of course, the usual collection of bugfixes
  
@@ -129,10 +30,12 @@ Changes in 1.9.x (since the 1.8.x series):
 
 ** `(srfi srfi-18)', more sophisticated multithreading support
 ** `(srfi srfi-27)', sources of random bits
+** `(srfi srfi-38)', External Representation for Data With Shared Structure
 ** `(srfi srfi-42)', eager comprehensions
 ** `(srfi srfi-45)', primitives for expressing iterative lazy algorithms
 ** `(srfi srfi-67)', compare procedures
 ** `(ice-9 i18n)', internationalization support
+** `(ice-9 futures)', fine-grain parallelism
 ** `(rnrs bytevectors)', the R6RS bytevector API
 ** `(rnrs io ports)', a subset of the R6RS I/O port API
 ** `(system xref)', a cross-referencing facility (FIXME undocumented)
@@ -141,6 +44,13 @@ Changes in 1.9.x (since the 1.8.x series):
 ** `(sxml match)', a pattern matcher for SXML
 ** `(srfi srfi-9 gnu)', extensions to the SRFI-9 record library
 ** `(system vm coverage)', a line-by-line code coverage library
+** `(web uri)', URI data type, parser, and unparser
+** `(web http)', HTTP header parsers and unparsers
+** `(web request)', HTTP request data type, reader, and writer
+** `(web response)', HTTP response data type, reader, and writer
+** `(web server)', Generic HTTP server
+** `(ice-9 poll)', a poll wrapper
+** `(web server http)', HTTP-over-TCP web server implementation
 
 ** Replaced `(ice-9 match)' with Alex Shinn's compatible, hygienic matcher.
     
@@ -206,6 +116,12 @@ debuggable.
 
 See "Invoking Guile" for more information on `--listen'.
 
+** Command line additions
+
+The guile binary now supports a new switch "-x", which can be used to
+extend the list of filename extensions tried when loading files
+(%load-extensions).
+
 ** New reader options: `square-brackets' and `r6rs-hex-escapes'
 
 The reader supports a new option (changeable via `read-options'),
@@ -276,6 +192,11 @@ control this. See "Value History" in the manual, for more 
information.
 When readline is enabled, tab completion works for arguments too, not
 just for the operator position.
 
+** Expression-oriented readline history
+    
+Guile's readline history now tries to operate on expressions instead of
+input lines.  Let us know what you think!
+
 ** Interactive Guile follows GNU conventions
 
 As recommended by the GPL, Guile now shows a brief copyright and
@@ -383,6 +304,20 @@ Scheme binding for the `getsid' C library call.
 
 Scheme binding for the `getaddrinfo' C library function.
 
+** Multicast socket options
+
+Support was added for the IP_MULTICAST_TTL and IP_MULTICAST_IF socket
+options.  See "Network Sockets and Communication" in the manual, for
+more information.
+
+** New GNU procedures: `setaffinity' and `getaffinity'.
+    
+See "Processes" in the manual, for more information.
+
+** New procedures: `compose', `negate', and `const'
+
+See "Higher-Order Functions" in the manual, for more information.
+
 ** New procedure in `(oops goops)': `method-formals'
 
 ** New procedures in (ice-9 session): `add-value-help-handler!',
@@ -429,7 +364,7 @@ Brainfuck language itself.
 
 Guile now has an experimental Emacs Lisp compiler and runtime. You can
 now switch to Elisp at the repl: `,language elisp'. All kudos to Daniel
-Kraft, and all bugs to address@hidden
+Kraft and Brian Templeton, and all bugs to address@hidden
 
 ** Better documentation infrastructure for macros
 
@@ -501,6 +436,11 @@ for more information.
 This procedure exports all current and future bindings from a module.
 Use as `(module-export-all! (current-module))'.
     
+** New procedure `reload-module', and `,reload' REPL command
+    
+See "Module System Reflection" and "Module Commands" in the manual, for
+more information.
+
 ** `eval-case' has been deprecated, and replaced by `eval-when'.
 
 The semantics of `eval-when' are easier to understand. See "Eval When"
@@ -985,6 +925,11 @@ There is a new `format' specifier, address@hidden', for 
doing a truncated
 print (as opposed to `~y', which does a pretty-print). See the `format'
 documentation for more details.
 
+** Better pretty-printing
+
+Indentation recognizes more special forms, like `syntax-case', and read
+macros like `quote' are printed better.
+
 ** Passing a number as the destination of `format' is deprecated
 
 The `format' procedure in `(ice-9 format)' now emits a deprecation
@@ -1412,7 +1357,19 @@ and is no longer used.
 
 `apply-to-args', `has-suffix?', `scheme-file-suffix'
 `get-option', `for-next-option', `display-usage-report',
-`transform-usage-lambda', `collect', `set-batch-mode?!'
+`transform-usage-lambda', `collect', `set-batch-mode?!',
+
+`cuserid' has been deprecated, as it only returns 8 bytes of a user's
+login.  Use `(passwd:name (getpwuid (geteuid)))' instead.
+    
+** Add support for unbound fluids
+    
+See `make-unbound-fluid', `fluid-unset!', and `fluid-bound?' in the
+manual.
+
+** Add `variable-unset!'
+    
+See "Variables" in the manual, for more details.
 
 ** Last but not least, the `λ' macro can be used in lieu of `lambda'
 
diff --git a/libguile/numbers.c b/libguile/numbers.c
index d5ebf9c..21f2383 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -1798,10 +1798,20 @@ SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
   SCM acc = SCM_I_MAKINUM (1L);
 
   SCM_VALIDATE_NUMBER (SCM_ARG1, n);
+  if (!SCM_I_INUMP (k) && !SCM_BIGP (k))
+    SCM_WRONG_TYPE_ARG (2, k);
 
-  /* 0^0 == 1 according to R5RS */
-  if (scm_is_eq (n, SCM_INUM0) || scm_is_eq (n, acc))
-    return scm_is_false (scm_zero_p(k)) ? n : acc;
+  if (scm_is_true (scm_zero_p (n)))
+    {
+      if (scm_is_true (scm_zero_p (k)))  /* 0^0 == 1 per R5RS */
+       return acc;        /* return exact 1, regardless of n */
+      else if (scm_is_true (scm_positive_p (k)))
+       return n;
+      else  /* return NaN for (0 ^ k) for negative k per R6RS */
+       return scm_nan ();
+    }
+  else if (scm_is_eq (n, acc))
+    return acc;
   else if (scm_is_eq (n, SCM_I_MAKINUM (-1L)))
     return scm_is_false (scm_even_p (k)) ? n : acc;
 
@@ -5479,8 +5489,29 @@ SCM_DEFINE (scm_expt, "expt", 2, 0, 0,
            "Return @var{x} raised to the power of @var{y}.") 
 #define FUNC_NAME s_scm_expt
 {
-  if (scm_is_true (scm_exact_p (x)) && scm_is_integer (y))
-    return scm_integer_expt (x, y);
+  if (scm_is_integer (y))
+    {
+      if (scm_is_true (scm_exact_p (y)))
+       return scm_integer_expt (x, y);
+      else
+       {
+         /* Here we handle the case where the exponent is an inexact
+            integer.  We make the exponent exact in order to use
+            scm_integer_expt, and thus avoid the spurious imaginary
+            parts that may result from round-off errors in the general
+            e^(y log x) method below (for example when squaring a large
+            negative number).  In this case, we must return an inexact
+            result for correctness.  We also make the base inexact so
+            that scm_integer_expt will use fast inexact arithmetic
+            internally.  Note that making the base inexact is not
+            sufficient to guarantee an inexact result, because
+            scm_integer_expt will return an exact 1 when the exponent
+            is 0, even if the base is inexact. */
+         return scm_exact_to_inexact
+           (scm_integer_expt (scm_exact_to_inexact (x),
+                              scm_inexact_to_exact (y)));
+       }
+    }
   else if (scm_is_real (x) && scm_is_real (y) && scm_to_double (x) >= 0.0)
     {
       return scm_from_double (pow (scm_to_double (x), scm_to_double (y)));
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index b365c64..b548ad8 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -2925,10 +2925,32 @@
 (with-test-prefix "expt"
   (pass-if-exception "non-numeric base" exception:wrong-type-arg
                      (expt #t 0))
-  (pass-if "(= 1 (expt 0 0))" (= 1 (expt 0 0)))
-  (pass-if "(= 1 (expt 0 0.0))" (= 1 (expt 0 0.0)))
-  (pass-if "(= 1 (expt 0.0 0))" (= 1 (expt 0.0 0)))
-  (pass-if "(= 1 (expt 0.0 0.0))" (= 1 (expt 0.0 0.0))))
+  (pass-if (eqv? 1 (expt 0 0)))
+  (pass-if (eqv? 1 (expt 0.0 0)))
+  (pass-if (eqv? 1.0 (expt 0 0.0)))
+  (pass-if (eqv? 1.0 (expt 0.0 0.0)))
+  (pass-if (nan? (expt 0 -1)))
+  (pass-if (nan? (expt 0 -1.0)))
+  (pass-if (nan? (expt 0.0 -1)))
+  (pass-if (nan? (expt 0.0 -1.0)))
+  (pass-if (eqv? 0 (expt 0 3)))
+  (pass-if (= 0 (expt 0 4.0)))
+  (pass-if (eqv? 0.0 (expt 0.0 5)))
+  (pass-if (eqv? 0.0 (expt 0.0 6.0)))
+  (pass-if (eqv? -2742638075.5 (expt -2742638075.5 1)))
+  (pass-if (eqv? (* -2742638075.5 -2742638075.5)
+                 (expt -2742638075.5 2)))
+  (pass-if (eqv? 4.0 (expt -2.0 2.0)))
+  (pass-if (eqv? -1/8 (expt -2 -3)))
+  (pass-if (eqv? -0.125 (expt -2.0 -3)))
+  (pass-if (eqv? -0.125 (expt -2 -3.0)))
+  (pass-if (eqv? -0.125 (expt -2.0 -3.0)))
+  (pass-if (eqv? 0.25 (expt 2.0 -2.0)))
+  (pass-if (eqv? (* -1.0 12398 12398) (expt +12398i 2.0)))
+  (pass-if (eqv-loosely? +i (expt -1 0.5)))
+  (pass-if (eqv-loosely? +i (expt -1 1/2)))
+  (pass-if (eqv-loosely? 1.0+1.7320508075688i (expt -8 1/3))))
+
 
 ;;;
 ;;; asinh
@@ -3050,7 +3072,23 @@
   (pass-if-exception "2^-inf" exception:wrong-type-arg
     (integer-expt 2 -inf.0))
   (pass-if-exception "2^nan" exception:wrong-type-arg
-    (integer-expt 2 +nan.0)))
+    (integer-expt 2 +nan.0))
+
+  (pass-if (eqv? 1 (integer-expt 0 0)))
+  (pass-if (eqv? 1 (integer-expt 0.0 0)))
+  (pass-if (nan? (integer-expt 0 -1)))
+  (pass-if (nan? (integer-expt 0.0 -1)))
+  (pass-if (eqv? 0 (integer-expt 0 3)))
+  (pass-if (eqv? 0.0 (integer-expt 0.0 5)))
+  (pass-if (eqv? -2742638075.5 (integer-expt -2742638075.5 1)))
+  (pass-if (eqv? (* -2742638075.5 -2742638075.5)
+                 (integer-expt -2742638075.5 2)))
+  (pass-if (eqv? 4.0 (integer-expt -2.0 2)))
+  (pass-if (eqv? -1/8 (integer-expt -2 -3)))
+  (pass-if (eqv? -0.125 (integer-expt -2.0 -3)))
+  (pass-if (eqv? 0.25 (integer-expt 2.0 -2)))
+  (pass-if (eqv? (* -1.0 12398 12398) (integer-expt +12398.0i 2))))
+
 
 ;;;
 ;;; integer-length


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]