help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: The next exercise


From: tomas
Subject: Re: The next exercise
Date: Fri, 9 Dec 2022 21:19:00 +0100

On Fri, Dec 09, 2022 at 08:58:32PM +0100, Michael Heerdegen wrote:
> Gregory Heytings <gregory@heytings.org> writes:
> 
> > M-: (substring (number-to-string (expt 1001 1000)) 0 3) RET
> >
> > "271"
> 
> Yes - correct!
> 
> My expectation was that someone would try Emacs Calc.  Because it can
> compute the number exactly - all digits.

These days, Emacs Lisp can, too (that was my mulling about
the gmp thingy ;-)

So...

  (let ((n 1) (exp 1000))
    (while (> exp 0)
      (setq n (* n 1001) exp (1- exp)))
    n)

also gives the exact number (guile is a /dash/ faster, but
Emacs Lisp ain't bad, either ;-)

AFAIK, Emacs uses libgmp for that.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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