昨天,我试着在我的SBCL盒(v.1.3.2 (x64),Windows 10,Dell Core i5 8GB内存)上计算出新的Mersenne (X64)的大小,几乎一个小时后我放弃并中断了计算。在生成的屏幕下面:
This is SBCL 1.3.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
WARNING: the Windows port is fragile, particularly for multithreaded
code. Unfortunately, the development team currently lacks the time
and resources this platform demands.
* (- (expt 2 74207281) 1)
debugger invoked on a SB-SYS:INTERACTIVE-INTERRUPT in thread
'#<THREAD "main thread" RUNNING {1002A9BD03}>:'
Interactive interrupt at #x100008BD9E.
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [CONTINUE] Return from SB-WIN32::SIGINT.
1: [ABORT ] Exit debugger, returning to top level.
1
(SB-BIGNUM:MULTIPLY-BIGNUMS #<unavailable argument> #<unavailable argument>)
0] 1对我来说,这很有趣,因为我在球拍6.4上,在同一台机器上尝试了同样的表达式,并且(相对地)只用了1m08s就开始吐痰了。在Haskell,又在同一台机器上
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> 2^74207281 - 1数字展览只花了8s就开始了。
尽管它可能是一个bug,但有人知道SBCL是如何做大乘法的吗?它的做法是否可能造成延误?
提前感谢!
*编辑
在西尔维斯特的评论之后,也许正确的问题是:是什么阻止了大数字被展示出来?是的,它确实很大(Racket和Haskell版本把它写到了一个21 MB的文本文件中),但是它的大小似乎是阻止任务完成的因素。
发布于 2016-02-23 16:55:04
实际计算在我的机器上相当快,实际上还不到一秒钟。
(defun make-prime ()
(declare (optimize (safety 0)(debug 0)(speed 3)))
(time (- (expt 2 74207281) 1)))
(defparameter *prime* (make-prime))
;Evaluation took:
; 0.000 seconds of real time
; 0.000017 seconds of total run time (0.000015 user, 0.000002 system)
; 100.00% CPU
; 1,292 processor cycles
; 0 bytes consed
; ==> *PRIME*然而,打印这个数字完全是另一回事。
https://stackoverflow.com/questions/35582932
复制相似问题