GNU bug report logs - #13031
large numbers

Previous Next

Package: guile;

Reported by: Jozef Chraplewski <jozef <at> applicake.com>

Date: Thu, 29 Nov 2012 17:51:02 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mark H Weaver <mhw <at> netris.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#13031: closed (large numbers)
Date: Fri, 07 Dec 2012 17:08:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 07 Dec 2012 12:06:41 -0500
with message-id <874njxbxlq.fsf <at> tines.lan>
and subject line Re: bug#13031: large numbers
has caused the debbugs.gnu.org bug report #13031,
regarding large numbers
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
13031: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13031
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Jozef Chraplewski <jozef <at> applicake.com>
To: bug-guile <at> gnu.org
Subject: large numbers
Date: Thu, 29 Nov 2012 09:42:09 +0100
Hi,

It looks that guile returns incorrect results when it works with really big numbers.

I've found it during resolving problem 48 from Project Euler:

http://projecteuler.net/problem=48

The solution is trivial:

(define (problem-48 limit)
 (define (F)
   (let loop ((n 1)
              (sum 0))
     (if (<= n limit)
         (loop (+ n 1) (+ sum (expt n n)))
         sum)))

 (let* ((str (number->string (F)))
          (len (string-length str)))
   (substring str (- len 10) len)))

(display (problem-48 1000))
(newline)


The proper answer is 9110846700 but guile returns 6457854188

I've tested solution under other scheme implementations (MIT scheme, petite and mzscheme) and it works as it should.

Does such a big numbers in guile require any special treatment or just they are not supported?

Best,
Jozef

[Message part 3 (message/rfc822, inline)]
From: Mark H Weaver <mhw <at> netris.org>
To: Jozef Chraplewski <jozef <at> applicake.com>
Cc: 13031-done <at> debbugs.gnu.org
Subject: Re: bug#13031: large numbers
Date: Fri, 07 Dec 2012 12:06:41 -0500
Hi Jozef,

Jozef Chraplewski <jozef <at> applicake.com> writes:
> Yes, I use 64-bit machine and (* (expt 2 32) (expt 2 32)) produces 0 (without the patch).
>
> I've applied your fix and it works perfectly.

Excellent!  Thanks for bringing this problem to our attention,
and for helping us track it down :)

> I suppose that you will add the patch to the next stable version (2.0.8 ??)

Yes.

   Thanks again,
       Mark


This bug report was last modified 12 years and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.