Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #41103

Re: Are Floating Point Numbers still a Can of Worms?

Path csiph.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Mostowski Collapse <janburse@fastmail.fm>
Newsgroups comp.lang.javascript
Subject Re: Are Floating Point Numbers still a Can of Worms?
Date Sat, 15 Oct 2022 14:25:39 +0200
Message-ID <tie8s2$am5d$1@solani.org> (permalink)
References <31753076-4806-4dd3-8577-40a4ed23b57dn@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 15 Oct 2022 12:25:38 -0000 (UTC)
Injection-Info solani.org; logging-data="350381"; mail-complaints-to="abuse@news.solani.org"
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0 SeaMonkey/2.53.14
Cancel-Lock sha1:72wgh1fGUYbcWPjEP2hEedUSj3M=
In-Reply-To <31753076-4806-4dd3-8577-40a4ed23b57dn@googlegroups.com>
X-User-ID eJwVysEBADEEBdGWCD7KSYT+S9jsdd6YgFGuMKiNDaWy1L6U2eyLXuzjHRL0H2vAHVvYw6zqqgCJXnKu8zz5ACwoFLQ=
Xref csiph.com comp.lang.javascript:41103

Show key headers only | View raw


I stepped over the example originally via Java and
not JavaScript. I find the following discrepancy between
JDK 19 and JDK 1.8, using Math.pow(), on Windows:

/* JDK 1.8 Windows Nok */
?- X is 1889**29.
X = 1.0250068783051206E95.

/* JDK 19 Windows Ok */
?- X is 1889**29.
X = 1.0250068783051207E95.

?- X is 1.0250068783051207E95-1.0250068783051206E95.
X = 1.4821387422376473E79.

Then I went on and tested nodeJS a little bit. You
can compare with Python as well. I get the following
result, namely the more accurate result, what the

HALF_EVEN rounding of the exact pow() gives:

/* Python 3.11.0rc1 Windows  Ok */
 >>> 1889**29.0
1.0250068783051207e+95

Would it be possible to upgrade nodeJS somehow?
Maybe I should post in a nodeJS forum. But the error
happens also in Browsers JavaScript, like in Chrome:

/* Chrome Windows Nok */
?- X is 1889**29.
X = 1.0250068783051206E95.

So I guess nodeJS might have imported the error from
Chrome V8 or something. It doesn't happen in FireFox:

/* FireFox Windows Ok */
?- X is 1889**29.
X = 1.0250068783051207E95.

Mostowski Collapse schrieb:
> Welcome to Node.js v18.9.0.
> 
>> 1889**29
> 1.0250068783051206e+95
>> Number(BigInt(1889)**BigInt(29))
> 1.0250068783051207e+95
> 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <bursejan@gmail.com> - 2022-10-14 15:52 -0700
  Re: Are Floating Point Numbers still a Can of Worms? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-15 01:52 +0100
  Re: Are Floating Point Numbers still a Can of Worms? "R.Wieser" <address@not.available> - 2022-10-15 09:33 +0200
    Re: Are Floating Point Numbers still a Can of Worms? "R.Wieser" <address@not.available> - 2022-10-15 10:00 +0200
    Re: Are Floating Point Numbers still a Can of Worms? John Harris <niam@jghnorth.org.uk.invalid> - 2022-10-15 11:13 +0100
      Re: Are Floating Point Numbers still a Can of Worms? "R.Wieser" <address@not.available> - 2022-10-15 13:43 +0200
        Re: Are Floating Point Numbers still a Can of Worms? John Harris <niam@jghnorth.org.uk.invalid> - 2022-10-15 15:56 +0100
          Re: Are Floating Point Numbers still a Can of Worms? "R.Wieser" <address@not.available> - 2022-10-15 17:44 +0200
  Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <janburse@fastmail.fm> - 2022-10-15 14:25 +0200
    Re: Are Floating Point Numbers still a Can of Worms? "R.Wieser" <address@not.available> - 2022-10-15 16:31 +0200
      Re: Are Floating Point Numbers still a Can of Worms? John Harris <niam@jghnorth.org.uk.invalid> - 2022-10-15 16:22 +0100
        Re: Are Floating Point Numbers still a Can of Worms? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-15 17:04 +0100
          Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <bursejan@gmail.com> - 2022-10-15 09:47 -0700
            Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <janburse@fastmail.fm> - 2022-10-15 18:51 +0200
              Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <bursejan@gmail.com> - 2022-10-22 14:35 -0700
                Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <bursejan@gmail.com> - 2022-11-21 09:02 -0800
  Re: Are Floating Point Numbers still a Can of Worms? Julio Di Egidio <julio@diegidio.name> - 2022-10-17 02:00 -0700
    Re: Are Floating Point Numbers still a Can of Worms? Mostowski Collapse <bursejan@gmail.com> - 2022-10-18 07:40 -0700

csiph-web