From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] A couple of small patches for 2.0 Date: Mon, 14 Feb 2011 17:16:15 -0500 Message-ID: <87sjvq6z4g.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1297721798 11081 80.91.229.12 (14 Feb 2011 22:16:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 14 Feb 2011 22:16:38 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Feb 14 23:16:34 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pp6ie-00083P-HG for guile-devel@m.gmane.org; Mon, 14 Feb 2011 23:16:32 +0100 Original-Received: from localhost ([127.0.0.1]:44026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pp6id-0005ZY-ND for guile-devel@m.gmane.org; Mon, 14 Feb 2011 17:16:31 -0500 Original-Received: from [140.186.70.92] (port=43305 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pp6iX-0005ZT-I4 for guile-devel@gnu.org; Mon, 14 Feb 2011 17:16:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pp6iW-00065T-22 for guile-devel@gnu.org; Mon, 14 Feb 2011 17:16:25 -0500 Original-Received: from world.peace.net ([216.204.32.208]:36899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pp6iV-00065L-TZ for guile-devel@gnu.org; Mon, 14 Feb 2011 17:16:24 -0500 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=freedomincluded) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1Pp6iQ-0004UE-8u; Mon, 14 Feb 2011 17:16:18 -0500 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1Pp6iP-0006DZ-8G; Mon, 14 Feb 2011 17:16:17 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 216.204.32.208 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11624 Archived-At: --=-=-= A couple of small patches for 2.0. Mark --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-minor-errors-in-docs-of-division-operators.patch Content-Description: Fix minor errors in docs of division operators >From ea77cc411665cc64de27896ca45c920e001f7820 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 13 Feb 2011 16:28:34 -0500 Subject: [PATCH 1/2] Fix minor errors in docs of division operators * doc/ref/api-data.texi (Arithmetic): The R5RS `quotient', `remainder', and `modulo' operators are exact-integer-only operators. `modulo' is equivalent to `floor-remainder', not `floor-quotient'. --- doc/ref/api-data.texi | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index a8cce24..5bef926 100644 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -1308,7 +1308,7 @@ both @var{q} and @var{r}, and is more efficient than computing each separately. Note that @var{r}, if non-zero, will have the same sign as @var{y}. -When @var{x} and @var{y} are integers, @code{floor-quotient} is +When @var{x} and @var{y} are exact integers, @code{floor-remainder} is equivalent to the R5RS integer-only operator @code{modulo}. @lisp @@ -1365,8 +1365,9 @@ both @var{q} and @var{r}, and is more efficient than computing each separately. Note that @var{r}, if non-zero, will have the same sign as @var{x}. -When @var{x} and @var{y} are integers, these operators are equivalent to -the R5RS integer-only operators @code{quotient} and @code{remainder}. +When @var{x} and @var{y} are exact integers, these operators are +equivalent to the R5RS integer-only operators @code{quotient} and +@code{remainder}. @lisp (truncate-quotient 123 10) @result{} 12 -- 1.7.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Use-trunc-instead-of-scm_c_truncate.patch Content-Description: Use trunc instead of scm_c_truncate >From 9149bf3cdccf6b281ffd416dacb254a6930fdc3a Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Mon, 14 Feb 2011 17:10:03 -0500 Subject: [PATCH 2/2] Use trunc instead of scm_c_truncate * libguile/numbers.c (scm_c_truncate, scm_truncate_number, scm_i_inexact_truncate_quotient, scm_i_inexact_truncate_remainder): Use trunc directly, now that we have its gnulib module. --- libguile/numbers.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/libguile/numbers.c b/libguile/numbers.c index 81d689d..59d8e74 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -2139,7 +2139,7 @@ scm_i_inexact_truncate_quotient (double x, double y) if (SCM_UNLIKELY (y == 0)) scm_num_overflow (s_scm_truncate_quotient); /* or return a NaN? */ else - return scm_from_double (scm_c_truncate (x / y)); + return scm_from_double (trunc (x / y)); } static SCM @@ -2274,7 +2274,7 @@ scm_i_inexact_truncate_remainder (double x, double y) if (SCM_UNLIKELY (y == 0)) scm_num_overflow (s_scm_truncate_remainder); /* or return a NaN? */ else - return scm_from_double (x - y * scm_c_truncate (x / y)); + return scm_from_double (x - y * trunc (x / y)); } static SCM @@ -8173,14 +8173,7 @@ static SCM scm_divide2real (SCM x, SCM y) double scm_c_truncate (double x) { -#if HAVE_TRUNC return trunc (x); -#else - if (x < 0.0) - return ceil (x); - else - return floor (x); -#endif } /* scm_c_round is done using floor(x+0.5) to round to nearest and with @@ -8233,7 +8226,7 @@ SCM_PRIMITIVE_GENERIC (scm_truncate_number, "truncate", 1, 0, 0, if (SCM_I_INUMP (x) || SCM_BIGP (x)) return x; else if (SCM_REALP (x)) - return scm_from_double (scm_c_truncate (SCM_REAL_VALUE (x))); + return scm_from_double (trunc (SCM_REAL_VALUE (x))); else if (SCM_FRACTIONP (x)) return scm_truncate_quotient (SCM_FRACTION_NUMERATOR (x), SCM_FRACTION_DENOMINATOR (x)); -- 1.7.1 --=-=-=--