Closed
Bug 459240
Opened 17 years ago
Closed 17 years ago
Off-by-one error breaks right shift operator for shift of 32
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: mozilla, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
Build Identifier: rhino1_7R1
x >> 32 should return 0, but returns x
Reproducible: Always
Steps to Reproduce:
% java org.mozilla.javascript.tools.shell.Main -e "print (0xFFFFFFFF >> 32)"
4294967295
% java org.mozilla.javascript.tools.shell.Main -e "print (0xFFFFFFFF >>> 32)"
4294967295
Actual Results:
(x >> 32) == x
(x >>> 32) == x
(x >> y) appears to be interpreted as (x >> (y % 32)) -- same for (x >>> y)
Expected Results:
(x >> 32) == 0
(x >>> 32) == 0
(x >> y) should be interpreted as (x >> (y % 33))
(x >>> y) should be interpreted as (x >>> (y % 33))
Comment 1•17 years ago
|
||
This is conformant to the ECMA-262 spec, sections 11.7.2 "The Signed Right Shift Operator" and 11.7.3. "The Unsigned Right Shift Operator". Both specify:
"7. Mask out all but the least significant 5 bits of Result(6), that is, compute Result(6) & 0x1F"
Where Result(6) refers to the shift offset value. This is effectively indeed making it modulo 32.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•