W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2012

[DOM3 Events] Error between float vs. double of WheelEvent

From: Masayuki Nakano <masayuki@d-toybox.com>
Date: Sun, 18 Mar 2012 10:57:04 +0900
Message-ID: <4F6540F0.80705@d-toybox.com>
To: "www-dom@w3.org" <www-dom@w3.org>
I'm now implementing D3E WheelEvent on Gecko.
https://bugzilla.mozilla.org/show_bug.cgi?id=719320

I realized that Gecko's javascript always use double for non-integer 
Number. Therefore, if I defined deltaX, deltaY and deltaZ as float, that 
could have caused error at copying float to double.

E.g., following function returns false when I defined them as float.

function () {
   var event = new WheelEvent("wheel", { deltaX: 1.0 });
   return (event.deltaX == 1.0);
}

because the deltaX becomes 1.000000xxxxxxxxx (x means random number) by 
the error.

I think that Gecko should define them as double for avoiding this bad 
behavior. Olli agreed with this idea at comment 6 in the bug.

However, this can make incompatibility with other browsers because this 
really depends on the JS implementation. I don't know whether I should 
suggest to change the definition from float to double or not. Some 
implementation might have same problem if the definition is changed so...

-- 
Masayuki Nakano <masayuki@d-toybox.com>
Manager, Internationalization, Mozilla Japan.
Received on Sunday, 18 March 2012 01:57:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:09 GMT