Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Dr J R Stockton Newsgroups: comp.lang.javascript Subject: Re: Why JavaScript has two zeros Date: Thu, 22 Dec 2016 23:43:21 +0000 Organization: Home Lines: 29 Message-ID: References: <84234e86-ac01-4a9e-9d21-dc1cdc30678c@googlegroups.com> <1bm6A.536745$IJ6.194196@fx46.am4> Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="2c9044a8c1bf9316db8b97a6f33340d2"; logging-data="31096"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1933vMT+qIipoaIbqp9Pd0NGk9imBBOnDY=" User-Agent: Turnpike/6.05-S () Cancel-Lock: sha1:Wk4rfGp48BSk/yAbgKfpkvTybaI= Xref: csiph.com comp.lang.javascript:31948 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.