[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile |
Date: |
Thu, 07 Apr 2011 17:50:09 +0200 |
User-agent: |
Gnus/5.110015 (No Gnus v0.15) Emacs/23.3 (gnu/linux) |
Hi!
Mark H Weaver <address@hidden> writes:
> exact-integer-sqrt is broken. It is now implemented in (rnrs base) by
> doing an inexact sqrt and coercing the answer to exact. This fails
> badly for large integers:
>
> scheme@(guile-user)> (use-modules ((rnrs base) #:version (6)))
> scheme@(guile-user)> (exact-integer-sqrt (expt 10 50))
> $1 = 10000000000000000905969664
> $2 = -18119393280000000820781032088272896
>
> This patch adds a proper implementation to guile core, which does this:
>
> scheme@(guile-user)> (exact-integer-sqrt (expt 10 50))
> $1 = 10000000000000000000000000
> $2 = 0
>
> I'd like to push this to stable-2.0. Any objections?
Not from me!
One remark:
> --- a/libguile/numbers.h
> +++ b/libguile/numbers.h
> @@ -289,6 +289,7 @@ SCM_API SCM scm_log (SCM z);
> SCM_API SCM scm_log10 (SCM z);
> SCM_API SCM scm_exp (SCM z);
> SCM_API SCM scm_sqrt (SCM z);
> +SCM_API void scm_exact_integer_sqrt (SCM k, SCM *s, SCM *r);
Shouldn’t it be SCM_INTERNAL? (If yes, then the doc should use @deffn
instead of @deftypefn.)
Thanks,
Ludo’.
- [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Mark H Weaver, 2011/04/06
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile,
Ludovic Courtès <=
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Mark H Weaver, 2011/04/07
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Ludovic Courtès, 2011/04/07
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Mark H Weaver, 2011/04/08
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Ludovic Courtès, 2011/04/09
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Mark H Weaver, 2011/04/09
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Ludovic Courtès, 2011/04/09
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Andy Wingo, 2011/04/11
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Detlev Zundel, 2011/04/11
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Noah Lavine, 2011/04/11
- Re: [PATCH] Fix the R6RS exact-integer-sqrt and import into core guile, Detlev Zundel, 2011/04/13