[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] New division operators, and optimization for fractions
From: |
Mark H Weaver |
Subject: |
Re: [PATCH] New division operators, and optimization for fractions |
Date: |
Tue, 15 Feb 2011 06:43:10 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
address@hidden (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!
>From 4a9c388d3c837244e358916beda59d4634121723 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <address@hidden>
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