Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Irrationality is the square root of all evil" -- Douglas Hofstadter


devel / comp.lang.scheme / Re: (expt 9.5 400) and (expt 9.4721 400)

SubjectAuthor
o Re: (expt 9.5 400) and (expt 9.4721 400)Paul Rubin

1
Re: (expt 9.5 400) and (expt 9.4721 400)

<87bkupob5s.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9970&group=comp.lang.scheme#9970

  copy link   Newsgroups: comp.lang.scheme
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.scheme
Subject: Re: (expt 9.5 400) and (expt 9.4721 400)
Date: Sat, 18 Jun 2022 15:32:31 -0700
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <87bkupob5s.fsf@nightsong.com>
References: <387f41b0-a309-491b-b4ce-3497d2c50772n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="c3bc43b87f7e12045c10ff09e459e8ad";
logging-data="17184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Sq4tOQM2xw9LQA3EH8WKA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:tJr0N5bneNC8s7znCvDBErQA62o=
sha1:0vSGrjz/2w0DifwNVtXrj+l3Usc=
 by: Paul Rubin - Sat, 18 Jun 2022 22:32 UTC

Hen Hanna <henhanna@gmail.com> writes:
> is there a way to do this?

The issue is that 9.5**400 is around 1e390 which is larger than the ieee
fp64 maximum value of around 1e308. While there is an extended format
with a wider range, it is probably simplest to use logarithms:

(define (log10 x) (/ (log x) (log 10.0)))

(define x0 (+ 5 (* 2 (sqrt 5)))) ; 9.472...

(define y0 (* 400.0 (log10 x0))) ; log10(x0**400)

(let* ((y1 (floor y0))
(y2 (- y0 y1)))
(display `(,(expt 10 y2) "* 10**" ,y1)))
(newline)

prints (3.794627652179525 * 10** 390.0) when I try it in Guile.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor