W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Conversion of ES Number to WebIDL long long and unsigned long long should not throw by default

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 07 Feb 2012 23:28:45 -0500
Message-ID: <4F31F9FD.9040300@mit.edu>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
The current WebIDL algorithm for long long says:

   Set x to sign(x) * floor(abs(x)).
   Set x to x modulo 2^64.
   If x is greater than or equal to 2^63, then set x to x − 2^64.
   If x < −(2^53 − 1) or x > 2^53 − 1, then throw a TypeError.

This makes no sense.  The justification is something about how your x 
might have lost precision and so you may not be hitting the 64-bit int 
you "wanted"... but in that case the check-and-throw should be done 
before reduction mod 2^64.  Doing it after just means the result is 
somewhat random once your double is greater than 2^64.

And if you to the check before reduction mod 2^64, then you just have 
the [EnforceRange] behavior, which people can already get if they want.

Received on Wednesday, 8 February 2012 04:32:33 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC