Re: SH: Integer limits

> On 12 Dec 2018, at 2:16 pm, Martin Thomson <martin.thomson@gmail.com> wrote:
> 
> Are you thinking 2^53-1 (the largest integer that can be faithfully
> represented in JS) or 2^32-1 (the largest integer that can be treated
> as an integer in JS)?

I was thinking of the former. For the latter, are you referring to this:

"""
Some ECMAScript operators deal only with integers in the range −2^31 through 2^31−1, inclusive, or in the range 0 through ^232−1, inclusive. These operators accept any value of the Number type but first convert each such value to one of 2^32 integer values. See the descriptions of the ToInt32 and ToUint32 operators in 9.5 and 9.6, respectively.
"""
 -- https://www.ecma-international.org/ecma-262/5.1/#sec-8.5

?

From looking at the rest of the spec briefly, it looks like we lose some bitwise and shift operators as a result -- is that correct? 

If so, my take would be that the higher limit is probably worth it; if a header needs to use bitwise/shift operators on large headers, that seems like something that could be dealt with in a few ways.


> I see from the reference you are probably thinking the former.  The
> latter might be safer if you can justify it though. Are there cases
> where the larger range might be needed?
> 
> I have a feeling that the answer is "yes", because 4Gb isn't that big
> a value and we have range header fields.  Is that what you are
> thinking?

Not specifically.



> On Wed, Dec 12, 2018 at 1:03 PM Mark Nottingham <mnot@mnot.net> wrote:
>> 
>> I've just opened <https://github.com/httpwg/http-extensions/issues/737>.
>> 
>> """
>> Working on evert/structured-headers, @evert noticed that representing the full range of SH integers is hard, and going beyond it can cause problems.
>> 
>> Given JS's place in the Web ecosystem and the relative rarity of headers that need integers that big (as well as the availability of floats), should we consider limiting the range of integer to match JS?
>> """
>> 
>> Relevant link: http://2ality.com/2013/10/safe-integers.html
>> 
>> 
>> Thoughts?
>> 
>> 
>> 
>> 
>> --
>> Mark Nottingham   https://www.mnot.net/
>> 
>> 
> 

--
Mark Nottingham   https://www.mnot.net/

Received on Wednesday, 12 December 2018 06:50:43 UTC