Path: csiph.com!1.us.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Are Floating Point Numbers still a Can of Worms? Date: Sat, 15 Oct 2022 17:04:16 +0100 Organization: A noiseless patient Spider Lines: 35 Message-ID: <87h705nke7.fsf@bsb.me.uk> References: <31753076-4806-4dd3-8577-40a4ed23b57dn@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="8e1c2f508dc719b9b49d4fb1f451084c"; logging-data="2957872"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1873MJQOG32+i+3ctqFP3GR6GRpWOZnO74=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:HSRZMr9dNS9Bvu5cMwAVrlpGl2M= sha1:yQnGBGj/K0oewFSvBe9pyu1LzFw= X-BSB-Auth: 1.bdd5c5e595f03eb497ca.20221015170416BST.87h705nke7.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:41108 John Harris writes: > On 15/10/2022 15:31, R.Wieser wrote: > > >> P.s. >> I've got some numbers for you : >> -- 1889*1889*1889*1889*1889* etc. calculated thru the FPU >> 53A891D176398773 - 1.0250068783051204e+095 > > > For what it's worth, the correct value of 1889**29 is : > > 102500687830512064253064716070601123218909116358654017979384519544555980744900395407329380298209 > > so the ...206 value is most accurate and ...207 is only slightly less > accurate. True. But neither 1.0250068783051206e95 nor 1.0250068783051207e95 can be represented in binary floating point. The two representable numbers closest to 1889**29 are 1025006878305120[5]6620692472528153354473784341513556365963141787204703693721957646169653433597952 and 1025006878305120[7]1442079894904626368690870422625608571181699824406695890772528399182534027509760 So the larger of the two is, in fact, the more accurate. There are two kinds of accuracy at this level: (1) what binary floating point number is the closest and, (2) what decimal is the closest representation to /that/ binary number? -- Ben.