f



Why JavaScript has two zeros

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/
0
abdulapopoola
12/20/2016 5:09:07 AM
comp.lang.javascript 38370 articles. 2 followers. javascript4 (1315) is leader. Post Follow

10 Replies
488 Views

Similar Articles

[PageSpeed] 21

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)
0
Evertjan
12/20/2016 10:46:59 AM
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,=20
  <snip>

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

  John
0
John
12/20/2016 5:58:02 PM
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)
0
Evertjan
12/20/2016 10:56:30 PM
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.
0
cyber
12/21/2016 2:55:57 AM
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=20
>comp.lang.javascript:
>
>> On Tue, 20 Dec 2016 11:46:59 +0100, "Evertjan."
>> <exxjxw.hannivoort@inter.nl.net> wrote:
>>=20
>>=20
>>   <snip>
>>>That the moon can be viewed as a Gouda cheese,=20
>>   <snip>
>>=20
>> 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
0
John
12/21/2016 1:59:46 PM
>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
0
Ram
12/21/2016 6:20:39 PM
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.


0
Dr
12/22/2016 11:43:21 PM
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)
0
Evertjan
12/23/2016 8:04:01 AM
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
0
Tim
12/23/2016 9:05:53 AM
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]?
0
Ram
12/24/2016 10:28:57 AM
Reply: