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


Groups > comp.lang.javascript > #31912 > unrolled thread

Why JavaScript has two zeros

Started byabdulapopoola@gmail.com
First post2016-12-19 21:09 -0800
Last post2016-12-26 12:03 -0800
Articles 16 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  Why JavaScript has two zeros abdulapopoola@gmail.com - 2016-12-19 21:09 -0800
    Re: Why JavaScript has two zeros "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-20 11:46 +0100
      Re: Why JavaScript has two zeros John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-20 17:58 +0000
        Re: Why JavaScript has two zeros "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-20 23:56 +0100
          Re: Why JavaScript has two zeros John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-21 13:59 +0000
    Re: Why JavaScript has two zeros <cyber@2trom.com> - 2016-12-21 02:55 +0000
      Re: Why JavaScript has two zeros Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-22 23:43 +0000
        Re: Why JavaScript has two zeros "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-12-23 09:04 +0100
          Re: Why JavaScript has two zeros Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-25 22:15 +0000
          Re: Why JavaScript has two zeros Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-25 23:39 +0000
        Re: Why JavaScript has two zeros Tim Streater <timstreater@greenbee.net> - 2016-12-23 09:05 +0000
        Re: Why JavaScript has two zeros Ram Tobolski <ramtob@gmail.com> - 2016-12-24 02:28 -0800
          Re: Why JavaScript has two zeros Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-12-25 22:00 +0000
      Re: Why JavaScript has two zeros "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-12-26 12:08 -0800
    Why JavaScript has two zeros Ram Tobolski <ramtob@gmail.com> - 2016-12-21 10:20 -0800
    Re: Why JavaScript has two zeros "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-12-26 12:03 -0800

#31912 — Why JavaScript has two zeros

Fromabdulapopoola@gmail.com
Date2016-12-19 21:09 -0800
SubjectWhy JavaScript has two zeros
Message-ID<84234e86-ac01-4a9e-9d21-dc1cdc30678c@googlegroups.com>
Do you know that there are actually two zero value types in JavaScript (as well as most languages)? Read to know why this matters, what scenarios to watch out for and some of the quirks of the IEEE 754 standard.

https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0/

[toc] | [next] | [standalone]


#31917

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-12-20 11:46 +0100
Message-ID<XnsA6E477DDCBF3Deejj99@194.109.6.166>
In reply to#31912
abdulapopoola@gmail.com wrote on 20 Dec 2016 in comp.lang.javascript:

> Do you know that there are actually two zero value types in JavaScript
> (as well as most languages)? Read to know why this matters, what
> scenarios to watch out for and some of the quirks of the IEEE 754
> standard. 
> 
> https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0
> / 

While the fact seems to be true, the posed argument:

"They can be viewed as vectors with zero magnitude pointing in opposite 
directions."

.. is bullshit.

That the moon can be viewed as a Gouda cheese, is also not a sound argument 
for more than helping a child to search a specified heavenly body in the 
night-sky only around full-moon day.



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31920

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-12-20 17:58 +0000
Message-ID<87si5ch0r6qb4habsqj6g8jgr9aht7911s@4ax.com>
In reply to#31917
On Tue, 20 Dec 2016 11:46:59 +0100, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:


  <snip>
>That the moon can be viewed as a Gouda cheese, 
  <snip>

Obviously it's not a Gouda cheese. It's Edam.

  John

[toc] | [prev] | [next] | [standalone]


#31925

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-12-20 23:56 +0100
Message-ID<XnsA6E4F38C33778eejj99@194.109.6.166>
In reply to#31920
John Harris <niam@jghnorth.org.uk.invalid> wrote on 20 Dec 2016 in 
comp.lang.javascript:

> On Tue, 20 Dec 2016 11:46:59 +0100, "Evertjan."
> <exxjxw.hannivoort@inter.nl.net> wrote:
> 
> 
>   <snip>
>>That the moon can be viewed as a Gouda cheese, 
>   <snip>
> 
> Obviously it's not a Gouda cheese. It's Edam.

True, I prefer Gouda and other slices than the full moon.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31937

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-12-21 13:59 +0000
Message-ID<5m2l5cpuka01nba4rpo75k0iouutofjt3b@4ax.com>
In reply to#31925
On Tue, 20 Dec 2016 23:56:30 +0100, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:

>John Harris <niam@jghnorth.org.uk.invalid> wrote on 20 Dec 2016 in 
>comp.lang.javascript:
>
>> On Tue, 20 Dec 2016 11:46:59 +0100, "Evertjan."
>> <exxjxw.hannivoort@inter.nl.net> wrote:
>> 
>> 
>>   <snip>
>>>That the moon can be viewed as a Gouda cheese, 
>>   <snip>
>> 
>> Obviously it's not a Gouda cheese. It's Edam.
>
>True, I prefer Gouda and other slices than the full moon.

I agree. Edam is nice but Gouda is nicer, as nice as Crumbly
Lancashire.

  John

[toc] | [prev] | [next] | [standalone]


#31931

From<cyber@2trom.com>
Date2016-12-21 02:55 +0000
Message-ID<1bm6A.536745$IJ6.194196@fx46.am4>
In reply to#31912
abdulapopoola@gmail.com wrote:
> Do you know that there are actually two zero value types in JavaScript (as well as most languages)? Read to know why this matters, what scenarios to watch out for and some of the quirks of the IEEE 754 standard.
> 
> https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0/

I imagine that also having -0i and 0i might be too complex for JavaScript.

[toc] | [prev] | [next] | [standalone]


#31948

FromDr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Date2016-12-22 23:43 +0000
Message-ID<LMKbWltZUGXYFwDf@invalid.uk.co.demon.merlyn.invalid>
In reply to#31931
In comp.lang.javascript message <1bm6A.536745$IJ6.194196@fx46.am4>, Wed,
21 Dec 2016 02:55:57, cyber@2trom.com posted:

>abdulapopoola@gmail.com wrote:
>> Do you know that there are actually two zero value types in
>>JavaScript (as well as most languages)? Read to know why this matters,
>>what scenarios to watch out for and some of the quirks of the IEEE 754
>>standard.
>>
>> https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0/
>
>I imagine that also having -0i and 0i might be too complex for JavaScript.

JavaScript has two zeroes (of equal but distinguishable values) because
IEEE 754 is a sign-magnitude-exponent representation.  They are the
reciprocals of the two infinities.  long-established readers with good
memories should recall at least one occasion on which having two zeroes
was arithmetically useful.

In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
arithmetic functions to operate on and return values of that nature.  It
is known that Math.POW(PlusI, PlusI) should return
0.207879576350761908546955... - and other values.

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

[toc] | [prev] | [next] | [standalone]


#31949

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-12-23 09:04 +0100
Message-ID<XnsA6E75C3BFEF28eejj99@194.109.6.166>
In reply to#31948
Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote on 23 Dec 2016 
in comp.lang.javascript:

> In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
> arithmetic functions to operate on and return values of that nature.  It
> is known that Math.POW(PlusI, PlusI) should return
> 0.207879576350761908546955... - and other values.

That I believe you are right is based on faith that it should, 
not on factual knowledge that it does or must. 

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#31958

FromDr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Date2016-12-25 22:15 +0000
Message-ID<wY4VzV2sTEYYFw8W@invalid.uk.co.demon.merlyn.invalid>
In reply to#31949
In comp.lang.javascript message <XnsA6E75C3BFEF28eejj99@194.109.6.166>,
Fri, 23 Dec 2016 09:04:01, Evertjan. <exxjxw.hannivoort@inter.nl.net>
posted:

>Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote on 23 Dec 2016
>in comp.lang.javascript:
>
>> In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
>> arithmetic functions to operate on and return values of that nature.  It
>> is known that Math.POW(PlusI, PlusI) should return
>> 0.207879576350761908546955... - and other values.
>
>That I believe you are right is based on faith that it should,
>not on factual knowledge that it does or must.


function i2i() {
  for (var N=-5 ; N<6 ; N++)
    document.writeln(N, "\t", Math.exp(-Math.PI/2 + 2*Math.PI*N))
  }

<https://en.wikipedia.org/wiki/Imaginary_unit#i_raised_to_the_power_of_i>

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

[toc] | [prev] | [next] | [standalone]


#31959

FromDr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Date2016-12-25 23:39 +0000
Message-ID<5rlnv29biFYYFwOD@invalid.uk.co.demon.merlyn.invalid>
In reply to#31949
In comp.lang.javascript message <XnsA6E75C3BFEF28eejj99@194.109.6.166>,
Fri, 23 Dec 2016 09:04:01, Evertjan. <exxjxw.hannivoort@inter.nl.net>
posted:

>Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote on 23 Dec 2016
>in comp.lang.javascript:
>
>> In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
>> arithmetic functions to operate on and return values of that nature.  It
>> is known that Math.POW(PlusI, PlusI) should return
>> 0.207879576350761908546955... - and other values.
>
>That I believe you are right is based on faith that it should,
>not on factual knowledge that it does or must.

Google knows it, four times, in three different languages.  It knows the
first nine fractional digits much better, and shows parts of at least
one simple proof.

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

[toc] | [prev] | [next] | [standalone]


#31950

FromTim Streater <timstreater@greenbee.net>
Date2016-12-23 09:05 +0000
Message-ID<231220160905534005%timstreater@greenbee.net>
In reply to#31948
In article <LMKbWltZUGXYFwDf@invalid.uk.co.demon.merlyn.invalid>, Dr J
R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote:

>In comp.lang.javascript message <1bm6A.536745$IJ6.194196@fx46.am4>, Wed,
>21 Dec 2016 02:55:57, cyber@2trom.com posted:
>
>>abdulapopoola@gmail.com wrote:
>>> Do you know that there are actually two zero value types in
>>>JavaScript (as well as most languages)? Read to know why this matters,
>>>what scenarios to watch out for and some of the quirks of the IEEE 754
>>>standard.
>>>
>>> https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0/
>>
>>I imagine that also having -0i and 0i might be too complex for JavaScript.
>
>JavaScript has two zeroes (of equal but distinguishable values) because
>IEEE 754 is a sign-magnitude-exponent representation.  They are the
>reciprocals of the two infinities. Long-established readers with good
>memories should recall at least one occasion on which having two zeroes
>was arithmetically useful.

Not sure I ever found it useful for integers - such as on the CDC 6000
series machines.

-- 
"Once you adopt the unix paradigm, the variants cease to be a problem - you
bitch, of course, but that's because bitching is fun, unlike M$ OS's, where 
bitching is required to keep your head from exploding." - S Stremler in afc

[toc] | [prev] | [next] | [standalone]


#31952

FromRam Tobolski <ramtob@gmail.com>
Date2016-12-24 02:28 -0800
Message-ID<1d5947b5-68d3-43e9-8f77-9e7156cdd48e@googlegroups.com>
In reply to#31948
On Friday, December 23, 2016 at 1:49:29 AM UTC+2, Dr J R Stockton wrote:
> In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
> arithmetic functions to operate on and return values of that nature.  It
> is known that Math.POW(PlusI, PlusI) should return
> 0.207879576350761908546955... - and other values.

What was the mathematical meaning of [0,+1] and [0,-1]?

[toc] | [prev] | [next] | [standalone]


#31957

FromDr J R Stockton <reply1600@merlyn.demon.co.uk.invalid>
Date2016-12-25 22:00 +0000
Message-ID<LIKbXh0lFEYYFw7A@invalid.uk.co.demon.merlyn.invalid>
In reply to#31952
In comp.lang.javascript message <1d5947b5-68d3-43e9-8f77-9e7156cdd48e@go
oglegroups.com>, Sat, 24 Dec 2016 02:28:57, Ram Tobolski
<ramtob@gmail.com> posted:

>On Friday, December 23, 2016 at 1:49:29 AM UTC+2, Dr J R Stockton wrote:
>> In JavaScript one can set PlusI = [0,+1] and MinusI = [0,-1], and write
>> arithmetic functions to operate on and return values of that nature.  It
>> is known that Math.POW(PlusI, PlusI) should return
>> 0.207879576350761908546955... - and other values.
>
>What was the mathematical meaning of [0,+1] and [0,-1]?

They represent +i & -i, of course; square roots of -1.  Some workers use
-j & +j (in that order) instead.

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

[toc] | [prev] | [next] | [standalone]


#31986

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-12-26 12:08 -0800
Message-ID<2f03fe9f-6523-4c2f-801b-de71b2a0e627@googlegroups.com>
In reply to#31931
On Tuesday, December 20, 2016 at 8:56:05 PM UTC-6, cy...@2trom.com wrote:

> I imagine that also having -0i and 0i might be too complex for JavaScript.

Hardly. The syntax is trivial, the semantics relatively straightforward. TC39 simply needs enough of a demand and time.

Related:

<http://wiki.ecmascript.org/doku.php?id=proposals:numbers>
<http://www.slideshare.net/BrendanEich/extensible-operators-and-literals-for-javascript>

[toc] | [prev] | [next] | [standalone]


#31940

FromRam Tobolski <ramtob@gmail.com>
Date2016-12-21 10:20 -0800
Message-ID<d7c516ec-91ca-4bf2-aa41-1c70f2fd3b60@googlegroups.com>
In reply to#31912
>Do you know that there are actually two zero value types in JavaScript (as well as most languages)? Read to know why this matters, what scenarios to watch out for and some of the quirks of the IEEE 754 standard. 
https://abdulapopoola.com/2016/12/19/why-javascript-has-two-zeros-0-and-0/ 

Nice

[toc] | [prev] | [next] | [standalone]


#31985

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-12-26 12:03 -0800
Message-ID<19a8ee00-26be-4d83-97fc-c0c8255a90d4@googlegroups.com>
In reply to#31912
More enlightening:

<https://en.wikipedia.org/wiki/Ones%27_complement>
<https://en.wikipedia.org/wiki/Two%27s_complement>
<https://en.wikipedia.org/wiki/IEEE_floating_point#IEEE_754-2008>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web