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


Groups > comp.lang.javascript > #28760

Re: Comparisson operators

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Comparisson operators
Date Tue, 29 Sep 2015 12:24:42 +0100
Organization A noiseless patient Spider
Lines 23
Message-ID <87twqdcvt1.fsf@bsb.me.uk> (permalink)
References <807dd61a-97ec-48cb-ad49-c6292a448a73@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="18456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189i4Ugbl8I7dNOiOJXZZ1EhfoV97hDaW0="
Cancel-Lock sha1:CoC2tgg14QEI+IcO4eaOeivwZ+c= sha1:EshrgdAnUq41xEJC8575kdnK1KM=
X-BSB-Auth 1.842c4744a3c848337c3f.20150929122442BST.87twqdcvt1.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:28760

Show key headers only | View raw


jonas.thornvall@gmail.com writes:

> Does the comparisson operators also suffer from the 32/64 bit integer limit?
> What happens if you assign a bigger value will it get truncated?

You should start by understanding what the type Number is in ECMAScript.
It is not an integer type in the usual sense of the word.  It is a
floating point type with very specific properties usually rather loosely
called "IEEE floating point".  It can, of course, store integer values,
but your reference to a "32/64 bit integer limit" suggests you don't
know what ECMAScript numbers are.

> 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.

-- 
Ben.

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


Thread

Comparisson operators jonas.thornvall@gmail.com - 2015-09-28 23:24 -0700
  Re: Comparisson operators "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-29 12:16 +0200
  Re: Comparisson operators Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-29 12:24 +0100
    Re: Comparisson operators Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-29 19:39 +0200
  Re: Comparisson operators Silvio <silvio@internet.com> - 2015-09-30 13:28 +0200

csiph-web