Summary: | Unary + conversion to number fails for negative hexadecimal (-0xff) 0x | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jorge <jorgechamorro> |
Component: | JavaScriptCore | Assignee: | Cameron Zwarich (cpst) <zwarich> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | barraclough, jorgechamorro, zwarich |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All | ||
URL: | http://groups.google.com/group/comp.lang.javascript/msg/8f8fcfdc42ee3960 |
Description
Jorge
2009-02-25 01:47:21 PST
This works as expected. See section 9.3.1 of the ECMA spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf The ToNumber operation (which is used by the unary plus operator) only handles negative signs for decimal numbers, not hex or octal. It might be a bit strange, but it's the spec. (In reply to comment #1) > > The ToNumber operation (which is used by the unary plus operator) only handles > negative signs for decimal numbers, not hex or octal. It might be a bit > strange, but it's the spec. FF, Opera and Chrome handle them fine, and that might be perceived as "better". Better than the spec -if you want- but better, after all. Now, what's the best browser ? Not Safari when it comes to hex string conversion to number... IMO, in this case better is better than the spec. Safari is doing it to/in-spec, but worse. If it's a potential compatibility issue down the road, then it probably makes sense to match Firefox on this. This was a bug in other browsers, and fixed in the latest FireFox. Behaves correctly. |