From: Blake Patterson
Subject: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <4afc4g$nsk@news.infi.net>
	I understand this _is_ possible under gcl with 'bignums.'  I
lack significant documentation of the language -- can anyone show me
some example code where bignums are used?  I need to (in case you missed
the topic) print out all the decimals in the computation of 2^850000.

	Thanks.

	Email is supernice.

bp
-- 
                                [[[ URL: http://www.pcs.cnu.edu/~bpatters ]]]
+--------------------------------- ---- -- -  -   -     -           -
|Blake W. Patterson         "I'm not quite clear about what you just spoke-
·········@pcs.cnu.edu        Was that a parable, or a very subtle joke?"   
······@vigsun1.larc.nasa.gov                                              
+--ToriAmos-LoreenaMcKennitt-Enya-DavidWilcox-SarahMcLachlan-ElvisCostello--+
+----DavidBowie-CrashTestDummies-TheyMightBeGiants-RustedRoot-Pixies-XTC----+

From: Jack Harper
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <jharper-1112950743540001@p19.denver1.dialup.csn.net>
In article <··········@news.infi.net>, ········@pcs.cnu.edu (Blake
Patterson) wrote:

>         I understand this _is_ possible under gcl with 'bignums.'  I
> lack significant documentation of the language -- can anyone show me
> some example code where bignums are used?  I need to (in case you missed
> the topic) print out all the decimals in the computation of 2^850000.
> 
>         Thanks.
> 
>         Email is supernice.
> 
> bp
> -- 
>                                 [[[ URL: http://www.pcs.cnu.edu/~bpatters ]]]
> +--------------------------------- ---- -- -  -   -     -           -
> |Blake W. Patterson         "I'm not quite clear about what you just spoke-
> ·········@pcs.cnu.edu        Was that a parable, or a very subtle joke?"   
> ······@vigsun1.larc.nasa.gov                                              
> +--ToriAmos-LoreenaMcKennitt-Enya-DavidWilcox-SarahMcLachlan-ElvisCostello--+
> +----DavidBowie-CrashTestDummies-TheyMightBeGiants-RustedRoot-Pixies-XTC----+

"Things should be as simple as possible...but no simpler" -- A. Einstein.

I would suggest:

    (expt 2 850000)

It might run for awhile -- but should work -- assuming you have enough memory.

Regards...

Jack Harper

---------------------------------------------------------------------
Jack Harper                             Bank Systems 2000, Inc.
e-mail: ·······@bs2000.com              350 Indiana Street, Suite 350
voice:  303-277-1892 fax: 303-277-1785  Golden, Colorado 80401 USA

                 "21st Century Banking Applications"
                Private Label Optical Bank Card Systems
            Visit our Web Page: http://www.bs2000.com/talos
---------------------------------------------------------------------
From: Jack Harper
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <jharper-1112951930490001@p23.denver1.dialup.csn.net>
<snip>

Oops...

You said GCL -- My error. See - Albert was right.

---------------------------------------------------------------------
Jack Harper                             Bank Systems 2000, Inc.
e-mail: ·······@bs2000.com              350 Indiana Street, Suite 350
voice:  303-277-1892 fax: 303-277-1785  Golden, Colorado 80401 USA

                 "21st Century Banking Applications"
                Private Label Optical Bank Card Systems
            Visit our Web Page: http://www.bs2000.com/talos
---------------------------------------------------------------------
From: Jean-David Marrow
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <4afsnf$70q@ixnews3.ix.netcom.com>
>	I understand this _is_ possible under gcl with 'bignums.'  I
>lack significant documentation of the language -- can anyone show me
>some example code where bignums are used?  I need to (in case you
missed
>the topic) print out all the decimals in the computation of 2^850000.

Too bad that you want decimals. In binary, of course, the answer is 1
followed by 850000 0's. :)

Sorry for the non-answer...

jdm
········@ix.netcom.com
From: Peter Adams
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <DJGBEI.GKA@actrix.gen.nz>
········@pcs.cnu.edu (Blake Patterson) wrote:


>	I understand this _is_ possible under gcl with 'bignums.'  I
>lack significant documentation of the language -- can anyone show me
>some example code where bignums are used?  I need to (in case you missed
>the topic) print out all the decimals in the computation of 2^850000.

>	Thanks.

>	Email is supernice.

>bp
>-- 
>                                [[[ URL: http://www.pcs.cnu.edu/~bpatters ]]]
>+--------------------------------- ---- -- -  -   -     -           -
>|Blake W. Patterson         "I'm not quite clear about what you just spoke-
>·········@pcs.cnu.edu        Was that a parable, or a very subtle joke?"   
>······@vigsun1.larc.nasa.gov                                              
>+--ToriAmos-LoreenaMcKennitt-Enya-DavidWilcox-SarahMcLachlan-ElvisCostello--+
>+----DavidBowie-CrashTestDummies-TheyMightBeGiants-RustedRoot-Pixies-XTC----+

If you want to see the result as a binary number it is simply 1
followed by 850000 zeros. You don't even need a Lisp program to tell
you that 8-)

The answer in decimal form would be 255,876 digits long (very nearly
60 pages at 60 lines to the page, and 72 digits to the line).

Here are two ways to calculate the answer in bignums. They work in ACL
so I preume the answer would be the same with GCL:

(defun pwr1 (lim)
   (do ((n 1) (count 0)) ((>= count lim) n)
      (setq n (* 2 n))
      (setq count (1+ count))))
;;
;;
(defun pwr2 (n)
   (cond
         ((= n 2) 4)
         ((oddp n) (* (pwr2 (- n 1)) 2))
         (t (square (pwr2 (/ n 2))))))
;;
;;
;;
I hope that your computer doesn't choke if you try to run the above
code using an argument value of 850,000 8-(.

Regards,


Peter Adams
From: Erik Naggum
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <19951212T140506Z@arcana.naggum.no>
[Peter Adams]

|   If you want to see the result as a binary number it is simply 1
|   followed by 850000 zeros.  You don't even need a Lisp program to tell
|   you that 8-)

this implies to me that (ash 1 850000) would do the job perfectly.

|   Here are two ways to calculate the answer in bignums.  They work in ACL
|   so I preume the answer would be the same with GCL:

GCL gets severely depressed when faced with very large bignums.  even after
(si::multiply-bignum-stack n), which is complains is necessary, it dumps
core with an "unrecoverable error".  (n = 20, n = 10 is too small, other
values not tested.)

#<Erik 3027765906>
-- 
suppose we actually were immortal...
what is the opposite of living your life as if every day were your last?
From: Pierpaolo Bernardi
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <4akem6$e2k@serra.unipi.it>
Peter Adams (······@actrix.gen.nz) wrote:
: ········@pcs.cnu.edu (Blake Patterson) wrote:


: >	I understand this _is_ possible under gcl with 'bignums.'  I
: >lack significant documentation of the language -- can anyone show me
: >some example code where bignums are used?  I need to (in case you missed
: >the topic) print out all the decimals in the computation of 2^850000.

: >	Thanks.

: >	Email is supernice.

: >bp
: >-- 

Using Clisp on a 486/66

(expt 2 850000)

takes about 3 min. 

Cheers.
From: John R. "Bob" Bane
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <4api72$1mn@tove.cs.umd.edu>
In article <··········@serra.unipi.it> ········@cli.di.unipi.it (Pierpaolo Bernardi) writes:
>
>Using Clisp on a 486/66
>
>(expt 2 850000)
>
>takes about 3 min. 
>
Try timing the following two forms:

(expt 2 850000)

(progn (setq foo (expt 2 850000)) nil)

I'll bet that the second one will be *much* faster than the first, which
has to spend a bunch of time converting the internal bignum representation
to decimal for printing.
-- 
Internet: ····@tove.cs.umd.edu
Voice: 301-552-4860
From: Pierpaolo Bernardi
Subject: Re: How do I calculate 2^850000 and see all the digits?
Date: 
Message-ID: <4ars81$1asm@serra.unipi.it>
John R. "Bob" Bane (····@cs.umd.edu) wrote:
: In article <··········@serra.unipi.it> ········@cli.di.unipi.it (Pierpaolo Bernardi) writes:
: >
: >Using Clisp on a 486/66
: >
: >(expt 2 850000)
: >
: >takes about 3 min. 
: >
: Try timing the following two forms:

: (expt 2 850000)

: (progn (setq foo (expt 2 850000)) nil)

: I'll bet that the second one will be *much* faster than the first, which
: has to spend a bunch of time converting the internal bignum representation
: to decimal for printing.
: -- 
: Internet: ····@tove.cs.umd.edu
: Voice: 301-552-4860

Of course.  The three minutes are for converting the thing in decimal.
Your second expression will probably run in no time flat.  

Cheers.  

P.