-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Semantics of JavaScript compiled >>
as intended?
#1434
Comments
The I thought the specified behavior of bitwise operations on the web are to use the underlying JS operations, possibly after some argument validation - we don't do (mod 32) on the shift counts. The JS operation coerces to Int32 first, then does 32-bit operations. Afterwards we convert the result to Uint32 (by doing Seems About specifying it, we already have something in the spec (an appendix) stating: item[$\bullet$]
Bitwise operations on integers (and, or, xor, negation, and shifts)
all truncate the operands to 32-bit two's complement integers,
perform 32-bit operations on those,
and the resulting 32 bits are interpreted as a 32-bit unsigned integer
(for example, \code{-1 <{}< 1} evaluates to 4294967294). That's apparently not precise when it comes to |
The non-negative input behaviour of I describe the behaviour as follows: |
It's not always the same So, to describe the operations, we do need to say that we truncate to 32 bits. The interesting thing about |
Here's a proposal for adding a few words to specify it: #1448. |
We are probably not going to change the semantics of
>>
when compiling to JavaScript, but the implemented behavior was actually surprising to me. Consider the following program:This shows that the
operator >>
onint
in JavaScript-compiled programs behaves as a signed shift on a bit string of length 33. The 32 bits are taken from the mantissa of the IEEE 754 representation, and the 33rd bit is the sign bit.If this is working as intended then we should specify it.
@rakudrama, @lrhn, @munificent, @leafpetersen, @stereotype441, @jakemac53, @natebosch, WDYT?
The text was updated successfully, but these errors were encountered: