Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Comparisson operators Date: Tue, 29 Sep 2015 19:39:09 +0200 Organization: PointedEars Software (PES) Lines: 30 Message-ID: <2785430.nENm2z7bcr@PointedEars.de> References: <807dd61a-97ec-48cb-ad49-c6292a448a73@googlegroups.com> <87twqdcvt1.fsf@bsb.me.uk> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1443548350 6989 eJwFwYkRACAIA7CV5Gk5xxGl+49ggqDxVhJMCPIKN66XXsrJmdhT3oIxGHobumu1nePW6P4JpBDw (29 Sep 2015 17:39:10 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 29 Sep 2015 17:39:10 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwNxMEBwEAEBMCWSHCUs5ztv4RkHuNvaMyx8DCnsyRt+molt9gEYumlQEueBf6d3QZBnzaK2Zk7mH00nvwAhfcW2w== Cancel-Lock: sha1:Q9jm2l37M67Rke8kZQtE6KF+gqk= X-NNTP-Posting-Host: eJwFwYEBwCAIA7CXEGiZ5yCu/59gguDiVBJMCNqmM8uDHeZ0sf3Isif+W8WSXcz+iDPeqHwZRxD5 Xref: csiph.com comp.lang.javascript:28762 Ben Bacarisse wrote: > jonas.thornvall@gmail.com writes: >> And what happen if you try to compare elements that is bigger than the >> scope of javascript integers? > > A normal floating-point comparison is done, just as it always is. What > matters is the range of integer values that can be represented exactly. > That range is -(2**53 - 1) to 2**53 - 1. The latest ECMAScript defines > property, Number.MAX_SAFE_INTEGER with the value 9007199254740991, but > you can always calculate Math.pow(2, 53) - 1. This description is so imprecise as to be misleading. Several integers smaller and greater than these boundaries can be stored exactly, but the integers *between* the boundaries and the stored integers cannot be, because the achievable precision is insufficient. Insofar Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER only give the minimum/maximum integer down/up to which proper arithmetic is possible (hence “SAFE”). The minimum/maximum integer than can be represented exactly with IEEE 754 doubles is approximately ±1.8 × 10³⁰⁸; it is exactly given by -Number.MAX_VALUE and Number.MAX_VALUE, respectively. (Note that Number.MIN_VALUE gives the smallest floating-point value greater than 0 instead.) -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.