unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] New division operators, and optimization for fractions
Date: Tue, 15 Feb 2011 06:43:10 -0500	[thread overview]
Message-ID: <87ei795xrl.fsf@netris.org> (raw)
In-Reply-To: <87sjvpk2gk.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 15 Feb 2011 11:38:03 +0100")

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:
> This patch series seems to break compilation on i686-linux-gnu:
>
>   http://hydra.nixos.org/build/913079
>
> The relevant part of the log is:
>
>   Running numbers.test
>   FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (130.0 10/7)
>   FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (130.0 -10/7)
>   FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (-130.0 10/7)
>   FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (-130.0 -10/7)

The following patch should fix it.

     Best,
      Mark

PS: Thanks for importing log1p so quickly!



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Use trunc in scm_i_inexact_truncate_divide --]
[-- Type: text/x-diff, Size: 1115 bytes --]

From 4a9c388d3c837244e358916beda59d4634121723 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Tue, 15 Feb 2011 06:10:06 -0500
Subject: [PATCH] Use trunc in scm_i_inexact_truncate_divide

* libguile/numbers.c (scm_i_inexact_truncate_divide): Use trunc instead
  of floor and ceil.  Important for consistency with
  scm_truncate_quotient and scm_truncate_remainder.
---
 libguile/numbers.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 59d8e74..7c4ea1b 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -2450,11 +2450,8 @@ scm_i_inexact_truncate_divide (double x, double y, SCM *qp, SCM *rp)
     scm_num_overflow (s_scm_truncate_divide);  /* or return a NaN? */
   else
     {
-      double q, r, q1;
-      /* FIXME: Use trunc, after it has been imported from gnulib */
-      q1 = x / y;
-      q = (q1 >= 0) ? floor (q1) : ceil (q1);
-      r = x - q * y;
+      double q = trunc (x / y);
+      double r = x - q * y;
       *qp = scm_from_double (q);
       *rp = scm_from_double (r);
     }
-- 
1.7.1


  reply	other threads:[~2011-02-15 11:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-10 23:42 [PATCH] New division operators, and optimization for fractions Mark H Weaver
2011-02-12 11:55 ` Andy Wingo
2011-02-14 13:56   ` Ken Raeburn
2011-02-14 18:17     ` Mark H Weaver
2011-02-15 10:38 ` Ludovic Courtès
2011-02-15 11:43   ` Mark H Weaver [this message]
2011-02-15 14:49     ` Ludovic Courtès
     [not found] <860989.4731.qm@web114104.mail.gq1.yahoo.com>
2011-02-12 20:19 ` Andy Wingo
2011-02-13 14:55   ` Mark H Weaver
2011-02-14 19:44     ` Andy Wingo
     [not found] <595618.30923.qm@web114107.mail.gq1.yahoo.com>
2011-02-12 21:54 ` Andy Wingo
2011-02-12 22:38   ` Mark Weaver

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87ei795xrl.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).