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


Groups > comp.lang.javascript > #33494

Re: x === x

From Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: x === x
Date 2017-06-02 22:12 +0100
Organization Home
Message-ID <oO0z22LMTdMZFwKM@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <JavaScript-20170530123255@ram.dialup.fu-berlin.de> <2563985.e9J7NaK4W3@PointedEars.de> <42992d96-86e3-4224-b011-5cb32f610a83@googlegroups.com> <5183822.MhkbZ0Pkbq@PointedEars.de>

Show all headers | View raw


In comp.lang.javascript message <5183822.MhkbZ0Pkbq@PointedEars.de>,
Wed, 31 May 2017 21:03:06, Thomas 'PointedEars' Lahn
<PointedEars@web.de> posted:

>Dr J R Stockton wrote:
>
>> […] Thomas 'PointedEars' Lahn wrote:
>>> This should be obvious even to you: The return values of consecutive
>>> calls of Math.random() may be, but are not supposed to be, equal.  After
>>> all, the method is supposed to generate *random* numbers.
>>
>> Standard ECMA-262, 6th Edition / June 2015, HTML, includes a
>> rather woolly "definition" :-
>
>That may be so, however the current Edition is the 7th (ECMAScript 2016).

Does the 7th edition differ in this respect?  I think not.  Both have a
missing hyphen.

>
>> […]
>>> > NaN === NaN
>>>
>>> This evaluating to “false” is due to the implementation of the
>>>ECMAScript
>>> Number type as a type of IEEE 754 “double-precision” floating-point
>>> values.
>>
>> I think not. IEEE 754 provides that a large number of 64-bit
>> patterns represent NaN, and I think it provides that all of
>> the patterns have the same arithmetic value. […]
>
>IEEE 754-1985 (at least) and (probably) IEEE 754-2008 (too) basically
>specify that (the) NaN (values) is/are not equal to any other floating-point
>value.

I hope not, as basically the word "other" should not be there.  It is
incorrectly restrictive.


>> The indistinguishability and inequality of NaNs in JavaScript
>> results from a choice taken by ECMA or by its relevant
>> predecessors.
>
>You are very likely mistaken there.

No.  IEEE 754 is only a local standard; it is not of itself
international, and in any case confers no legal obligation; and it was
the choice of ECMA/predecessors (and also of FPU designers) to follow
that standard.  Recall that ISO 8601 is an International Standard, yet
is generally ignored by the less intelligent, especially in the USA.

Borland Delphi, however, follows IEEE 754, and in arithmetic expressions
NaNs are indistinguishable.  But the language, unlike JavaScript, allows
(for example) any consecutive 8 bytes (possibly starting on a 2^K byte
boundary) to be used *NOT ONLY* as an IEEE 754 Double *BUT ALSO* as 8
unsigned 8-bit integers or (IIRC) a 64-bit integer, etc.  In those
views, all possible NaNs are distinguishable.

The ECMA choice that really matters here is not the adoption of IEEE
754, but the invisibility of the entrails of an Object.

Recall the slightly analogous situation of +0 & -0.  They have the same
value, by the usual tests for equality.  Nevertheless, they are
distinguishable; 1/(+0) is infinitely different from 1/(-0).  It seems
somewhat likely that NaN/(+0) and NaN/(-0) are indistinguishably
different in at least some implementations.

-- 
 (c) John Stockton, Surrey, UK.  ¬@merlyn.demon.co.uk   Turnpike v6.05   MIME.
 Merlyn Web Site <                       > - FAQish topics, acronyms, & links.

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


Thread

Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-30 16:21 +0200
  Re: x === x John G Harris <niam@jghnorth.org.uk.invalid> - 2017-05-30 19:16 +0100
  Re: x === x Dr J R Stockton <J.R.Stockton@physics.org> - 2017-05-31 08:39 -0700
    Re: x === x Stefan Weiss <krewecherl@gmail.com> - 2017-05-31 18:08 +0200
      Re: x === x Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-06-02 22:27 +0100
    Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-31 21:03 +0200
      Re: x === x Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-06-02 22:12 +0100
    Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-31 21:09 +0200
      Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 01:58 +0100
        Re: x === x Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-06-01 05:01 +0200
          Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 14:44 +0100
          Re: x === x Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-06-02 21:15 +0100
        Re: x === x Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 14:17 +0100
    Re: x === x Julio Di Egidio <julio@diegidio.name> - 2017-06-01 00:10 -0700
      Re: x === x Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-06-02 22:16 +0100

csiph-web