ran*_*and 2 lisp sbcl common-lisp
昨天我试图在我的SBCL盒子(v.1.3.2(x64),Windows 10,戴尔Core)上找出新Mersenne Prime(http://www.mersenne.org/primes/?press=M74207281)的大小i5 8GB RAM)差不多一个小时后,我放弃了并中断了计算.在结果屏幕下方:
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
Run Code Online (Sandbox Code Playgroud)
对我来说这很有意思,因为我在同一台机器上的Racket 6.4上尝试了相同的表达式,而且(相对而言)只需要1m08就能开始吐出数字.在Haskell,再次在同一台机器上,用
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> 2^74207281 - 1
Run Code Online (Sandbox Code Playgroud)
只用了8秒就开始了数字展览.
尽管它可能是一个bug,但有人知道SBCL如何进行bignum乘法吗?它的做法是否可能导致延误?
提前致谢!
*编辑
在西尔维斯特的评论之后,也许正确的问题是:什么阻止大数字显示?是的,它确实很大(Racket和Haskell版本将其写入21 MB的文本文件),但似乎有一些超过它的大小阻止任务完成.
实际计算在我的机器上非常快,实际上不到一秒钟.
(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*
Run Code Online (Sandbox Code Playgroud)
然而,打印数字是另一回事.
| 归档时间: |
|
| 查看次数: |
278 次 |
| 最近记录: |