bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13031: large numbers


From: Stefan Israelsson Tampe
Subject: bug#13031: large numbers
Date: Thu, 29 Nov 2012 20:15:26 +0100

Hi,

Which version of guile do you use, I get the correct value for guile 2.0.5.91-de6d8

/Stefan


On Thu, Nov 29, 2012 at 9:42 AM, Jozef Chraplewski <address@hidden> wrote:
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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]