-
Notifications
You must be signed in to change notification settings - Fork 57
Unsigned right shift semantics #6
Comments
I would prefer parity with current Imposing different rules for different integer types ( |
@kgryte Are you saying that we should do option 1 that I listed above? |
Would you be willing to provide examples showing how |
|
A sensible meaning for |
@lars-t-hansen The absolute value semantics was also suggested by @rauschma , but it seems surprising to me. |
I’ve since changed my mind, since negativity for BigInts is more like an orthogonal (out-of-band) flag and not directly encoded as a bit, as it is with a fixed amount of bits (e.g. 32 bits for JS Numbers). |
OK, it still seems like there isn't a great meaning for |
Is there much meaning to unsigned right shift? With arbitrary-precision integers, there's not much meaning to 'signed' and 'unsigned', as we don't have any particular need to downcast to a signed or unsigned fixed width integer, as
>>
/>>>
does on Numbers. For users who want to get at a 64-bit signed/unsigned integer's right shift functionality, that can be accessed by putting the left operand within the 64-bit signed or unsigned integer range.I see a couple viable options for the semantics of
>>>
:>>
and>>>
do the same thing>>>
throws a TypeErrorMy personal preference is for 2. There's no need to expose duplicate functionality under another name, and not exposing it would give us space to give it other semantics in the future if we find a need. BigInt is generally designed with generic code that works between Numbers and BigInts as an explicit non-goal, so there is no particular need to support
>>>
at all.In earlier conversation with @msaboff, we discussed the possibility of some other semantics for
>>>
, but Waldemar Horwat pointed out that the bitwidth of a BigInt is not sufficiently defined to make that meaningful.The text was updated successfully, but these errors were encountered: